1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
// Namespace: "chat.1"
// Protocol: "common"
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Serialize, Deserialize};
use serde_repr::{Deserialize_repr, Serialize_repr};use super::*;

use crate::protocol::gregor1;
use crate::protocol::keybase1;
pub type ThreadID = String;

// LINT: @lint("ignore")
pub type MessageID = u32;

// LINT: @lint("ignore")
pub type TLFConvOrdinal = u32;

pub type TopicID = String;

pub type ConversationID = String;

pub type TLFID = String;

pub type Hash = String;

// LINT: @lint("ignore")
pub type InboxVers = u64;

// LINT: @lint("ignore")
pub type LocalConversationVers = u64;

// LINT: @lint("ignore")
pub type ConversationVers = u64;

pub type OutboxID = String;

pub type TopicNameState = String;

pub type FlipGameID = String;

#[derive(Serialize, Deserialize, Debug)]
pub struct InboxVersInfo {
  pub uid: Option<gregor1::UID>,
  pub vers: Option<InboxVers>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ConversationExistence {
  Active_0,
  Archived_1,
  Deleted_2,
  Abandoned_3,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ConversationMembersType {
  Kbfs_0,
  Team_1,
  Impteamnative_2,
  Impteamupgrade_3,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum SyncInboxResType {
  Current_0,
  Incremental_1,
  Clear_2,
}

// @go("nostring")
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum MessageType {
  None_0,
  Text_1,
  Attachment_2,
  Edit_3,
  Delete_4,
  Metadata_5,
  Tlfname_6, // Only used as the very first message in conversations whose topic name is not set when created
  Headline_7,
  Attachmentuploaded_8, // sent after upload completes to modify ATTACHMENT message
  Join_9, // sent when joining a channel
  Leave_10,
  System_11, // messages that get autogenerated by people's clients
  Deletehistory_12,
  Reaction_13,
  Sendpayment_14,
  Requestpayment_15,
  Unfurl_16,
  Flip_17,
}

// @go("nostring")
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum TopicType {
  None_0,
  Chat_1,
  Dev_2,
  Kbfsfileedit_3,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum TeamType {
  None_0,
  Simple_1,
  Complex_2,
}

// @go("nostring")
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum NotificationKind {
  Generic_0,
  Atmention_1,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum GlobalAppNotificationSetting {
  Newmessages_0,
  Plaintextmobile_1,
  Plaintextdesktop_2,
  Defaultsoundmobile_3,
  Disabletyping_4,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GlobalAppNotificationSettings {
  pub settings: Option<std::collections::HashMap<GlobalAppNotificationSetting, bool>>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ConversationStatus {
  Unfiled_0,
  Favorite_1,
  Ignored_2,
  Blocked_3,
  Muted_4,
  Reported_5,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationMember {
  pub uid: Option<gregor1::UID>,
  pub convID: Option<ConversationID>,
  pub topicType: Option<TopicType>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationIDMessageIDPair {
  pub convID: Option<ConversationID>,
  pub msgID: Option<MessageID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationIDMessageIDPairs {
  #[serde(default)]
  pub pairs: Option<Vec<ConversationIDMessageIDPair>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChannelNameMention {
  pub convID: Option<ConversationID>,
  #[serde(default)]
  pub topicName: Option<String>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ConversationMemberStatus {
  Active_0, // in the channel
  Removed_1, // removed from channel forcibly
  Left_2, // voluntarily left conversation
  Preview_3, // use is previewing the channel from an @mention
  Reset_4, // status of having an account reset in an impteam
  Never_joined_5, // member of the team but never joined the conv
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Pagination {
  #[serde(default)]
  pub next: Option<String>,
  #[serde(default)]
  pub previous: Option<String>,
  pub num: Option<i32>,
  #[serde(default)]
  pub last: Option<bool>,
  #[serde(default)]
  pub forceFirstPage: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RateLimit {
  #[serde(default)]
  pub name: Option<String>,
  pub callsRemaining: Option<i32>,
  pub windowReset: Option<i32>,
  pub maxCalls: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GetInboxQuery {
  pub convID: Option<ConversationID>,
  pub topicType: Option<TopicType>,
  pub tlfID: Option<TLFID>,
  pub tlfVisibility: Option<keybase1::TLFVisibility>,
  pub before: Option<gregor1::Time>,
  pub after: Option<gregor1::Time>,
  pub oneChatTypePerTLF: Option<bool>,
  pub topicName: Option<String>,
  #[serde(default)]
  pub status: Option<Vec<ConversationStatus>>,
  #[serde(default)]
  pub memberStatus: Option<Vec<ConversationMemberStatus>>,
  #[serde(default)]
  pub existences: Option<Vec<ConversationExistence>>,
  #[serde(default)]
  pub membersTypes: Option<Vec<ConversationMembersType>>,
  #[serde(default)]
  pub convIDs: Option<Vec<ConversationID>>,
  #[serde(default)]
  pub unreadOnly: Option<bool>,
  #[serde(default)]
  pub readOnly: Option<bool>,
  #[serde(default)]
  pub computeActiveList: Option<bool>,
  #[serde(default)]
  pub summarizeMaxMsgs: Option<bool>,
  #[serde(default)]
  pub skipBgLoads: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationIDTriple {
  // @lint("ignore")
  pub tlfid: Option<TLFID>,
  pub topicType: Option<TopicType>,
  pub topicID: Option<TopicID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationFinalizeInfo {
  #[serde(default)]
  pub resetUser: Option<String>,
  #[serde(default)]
  pub resetDate: Option<String>,
  #[serde(default)]
  pub resetFull: Option<String>,
  pub resetTimestamp: Option<gregor1::Time>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationResolveInfo {
  #[serde(default)]
  pub newTLFName: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Expunge {
  pub upto: Option<MessageID>,
  pub basis: Option<MessageID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationMetadata {
  pub idTriple: Option<ConversationIDTriple>,
  pub conversationID: Option<ConversationID>,
  pub visibility: Option<keybase1::TLFVisibility>,
  pub status: Option<ConversationStatus>,
  pub membersType: Option<ConversationMembersType>,
  pub teamType: Option<TeamType>,
  pub existence: Option<ConversationExistence>,
  pub version: Option<ConversationVers>,
  pub localVersion: Option<LocalConversationVers>,
  pub finalizeInfo: Option<ConversationFinalizeInfo>,
  #[serde(default)]
  pub supersedes: Option<Vec<ConversationMetadata>>,
  #[serde(default)]
  pub supersededBy: Option<Vec<ConversationMetadata>>,
  #[serde(default)]
  pub activeList: Option<Vec<gregor1::UID>>,
  #[serde(default)]
  pub allList: Option<Vec<gregor1::UID>>,
  #[serde(default)]
  pub resetList: Option<Vec<gregor1::UID>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationNotificationInfo {
  #[serde(default)]
  pub channelWide: Option<bool>,
  pub settings: Option<std::collections::HashMap<keybase1::DeviceType, std::collections::HashMap<NotificationKind, bool>>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationReaderInfo {
  pub mtime: Option<gregor1::Time>,
  pub readMsgid: Option<MessageID>,
  pub maxMsgid: Option<MessageID>,
  pub status: Option<ConversationMemberStatus>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationCreatorInfo {
  pub ctime: Option<gregor1::Time>,
  pub uid: Option<gregor1::UID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationCreatorInfoLocal {
  pub ctime: Option<gregor1::Time>,
  #[serde(default)]
  pub username: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationMinWriterRoleInfo {
  pub uid: Option<gregor1::UID>,
  pub role: Option<keybase1::TeamRole>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConversationSettings {
  // @mpackkey("mwr")
  #[serde(rename = "mwr")]
  pub minWriterRoleInfo: Option<ConversationMinWriterRoleInfo>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Conversation {
  pub metadata: Option<ConversationMetadata>,
  pub readerInfo: Option<ConversationReaderInfo>,
  pub notifications: Option<ConversationNotificationInfo>,
  #[serde(default)]
  pub maxMsgs: Option<Vec<MessageBoxed>>,
  #[serde(default)]
  pub maxMsgSummaries: Option<Vec<MessageSummary>>,
  pub creatorInfo: Option<ConversationCreatorInfo>,
  pub expunge: Option<Expunge>,
  pub convRetention: Option<RetentionPolicy>,
  pub teamRetention: Option<RetentionPolicy>,
  // @mpackkey("cs")
  #[serde(rename = "cs")]
  pub convSettings: Option<ConversationSettings>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MessageSummary {
  pub msgID: Option<MessageID>,
  pub messageType: Option<MessageType>,
  #[serde(default)]
  pub tlfName: Option<String>,
  #[serde(default)]
  pub tlfPublic: Option<bool>,
  pub ctime: Option<gregor1::Time>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Reaction {
  pub ctime: Option<gregor1::Time>,
  pub reactionMsgID: Option<MessageID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ReactionMap {
  pub reactions: Option<std::collections::HashMap<String, std::collections::HashMap<String, Reaction>>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MessageServerHeader {
  pub messageID: Option<MessageID>,
  pub supersededBy: Option<MessageID>,
  // @mpackkey("r")
  #[serde(rename = "r")]
  #[serde(default)]
  pub reactionIDs: Option<Vec<MessageID>>,
  // @mpackkey("u")
  #[serde(rename = "u")]
  #[serde(default)]
  pub unfurlIDs: Option<Vec<MessageID>>,
  #[serde(default)]
  pub replies: Option<Vec<MessageID>>,
  pub ctime: Option<gregor1::Time>,
  // @mpackkey("n")
  #[serde(rename = "n")]
  pub now: Option<gregor1::Time>,
  // @mpackkey("rt")
  #[serde(rename = "rt")]
  pub rtime: Option<gregor1::Time>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MessagePreviousPointer {
  pub id: Option<MessageID>,
  #[serde(default)]
  pub hash: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct OutboxInfo {
  pub prev: Option<MessageID>,
  pub composeTime: Option<gregor1::Time>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MsgEphemeralMetadata {
  // @mpackkey("l")
  #[serde(rename = "l")]
  pub lifetime: Option<gregor1::DurationSec>,
  // @mpackkey("g")
  #[serde(rename = "g")]
  pub generation: Option<keybase1::EkGeneration>,
  // @mpackkey("u")
  #[serde(rename = "u")]
  pub explodedBy: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EphemeralPurgeInfo {
  // @mpackkey("c")
  #[serde(rename = "c")]
  pub convID: Option<ConversationID>,
  // @mpackkey("a")
  #[serde(rename = "a")]
  #[serde(default)]
  pub isActive: Option<bool>,
  // @mpackkey("n")
  #[serde(rename = "n")]
  pub nextPurgeTime: Option<gregor1::Time>,
  // @mpackkey("e")
  #[serde(rename = "e")]
  pub minUnexplodedID: Option<MessageID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MessageClientHeader {
  pub conv: Option<ConversationIDTriple>,
  #[serde(default)]
  pub tlfName: Option<String>,
  #[serde(default)]
  pub tlfPublic: Option<bool>,
  pub messageType: Option<MessageType>,
  pub supersedes: Option<MessageID>,
  pub kbfsCryptKeysUsed: Option<bool>,
  #[serde(default)]
  pub deletes: Option<Vec<MessageID>>,
  #[serde(default)]
  pub prev: Option<Vec<MessagePreviousPointer>>,
  pub deleteHistory: Option<MessageDeleteHistory>,
  pub sender: Option<gregor1::UID>,
  pub senderDevice: Option<gregor1::DeviceID>,
  pub merkleRoot: Option<MerkleRoot>,
  pub outboxID: Option<OutboxID>,
  pub outboxInfo: Option<OutboxInfo>,
  // @mpackkey("em")
  #[serde(rename = "em")]
  pub ephemeralMetadata: Option<MsgEphemeralMetadata>,
  // @mpackkey("pm")
  #[serde(rename = "pm")]
  pub pairwiseMacs: Option<std::collections::HashMap<keybase1::KID, String>>,
  // @mpackkey("b")
  #[serde(rename = "b")]
  pub botUID: Option<gregor1::UID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MessageClientHeaderVerified {
  pub conv: Option<ConversationIDTriple>,
  #[serde(default)]
  pub tlfName: Option<String>,
  #[serde(default)]
  pub tlfPublic: Option<bool>,
  pub messageType: Option<MessageType>,
  #[serde(default)]
  pub prev: Option<Vec<MessagePreviousPointer>>,
  pub sender: Option<gregor1::UID>,
  pub senderDevice: Option<gregor1::DeviceID>,
  pub kbfsCryptKeysUsed: Option<bool>,
  pub merkleRoot: Option<MerkleRoot>,
  pub outboxID: Option<OutboxID>,
  pub outboxInfo: Option<OutboxInfo>,
  // @mpackkey("em")
  #[serde(rename = "em")]
  pub ephemeralMetadata: Option<MsgEphemeralMetadata>,
  // @mpackkey("rt")
  #[serde(rename = "rt")]
  pub rtime: Option<gregor1::Time>,
  // @mpackkey("pm")
  #[serde(rename = "pm")]
  #[serde(default)]
  pub hasPairwiseMacs: Option<bool>,
  // @mpackkey("b")
  #[serde(rename = "b")]
  pub botUID: Option<gregor1::UID>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EncryptedData {
  pub v: Option<i32>,
  #[serde(default)]
  pub e: Option<String>,
  #[serde(default)]
  pub n: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SignEncryptedData {
  pub v: Option<i32>,
  #[serde(default)]
  pub e: Option<String>,
  #[serde(default)]
  pub n: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SealedData {
  pub v: Option<i32>,
  #[serde(default)]
  pub e: Option<String>,
  #[serde(default)]
  pub n: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SignatureInfo {
  pub v: Option<i32>,
  #[serde(default)]
  pub s: Option<String>,
  #[serde(default)]
  pub k: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct MerkleRoot {
  pub seqno: Option<i64>,
  #[serde(default)]
  pub hash: Option<String>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum InboxResType {
  Versionhit_0,
  Full_1,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct InboxViewFull {
  pub vers: Option<InboxVers>,
  #[serde(default)]
  pub conversations: Option<Vec<Conversation>>,
  pub pagination: Option<Pagination>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum InboxView {
  Versionhit {versionhit: ()},
  Full {full: InboxViewFull},
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum RetentionPolicyType {
  None_0,
  Retain_1, // Keep messages forever
  Expire_2, // Delete after a while
  Inherit_3, // Use the team's policy
  Ephemeral_4, // Force all messages to be exploding.
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum RetentionPolicy {
  Retain {retain: RpRetain},
  Expire {expire: RpExpire},
  Inherit {inherit: RpInherit},
  Ephemeral {ephemeral: RpEphemeral},
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RpRetain {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RpExpire {
  pub age: Option<gregor1::DurationSec>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RpInherit {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct RpEphemeral {
  pub age: Option<gregor1::DurationSec>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum GetThreadReason {
  General_0,
  Push_1,
  Foreground_2,
  Backgroundconvload_3,
  Fixretry_4,
  Prepare_5,
  Searcher_6,
  Indexed_search_7,
  Kbfsfileactivity_8,
  Coinflip_9,
  Botcommands_10,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum ReIndexingMode {
  None_0,
  Presearch_sync_1,
  Postsearch_sync_2,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SearchOpts {
  #[serde(default)]
  pub isRegex: Option<bool>,
  #[serde(default)]
  pub sentBy: Option<String>,
  #[serde(default)]
  pub sentTo: Option<String>,
  #[serde(default)]
  pub matchMentions: Option<bool>,
  pub sentBefore: Option<gregor1::Time>,
  pub sentAfter: Option<gregor1::Time>,
  pub maxHits: Option<i32>,
  pub maxMessages: Option<i32>,
  pub beforeContext: Option<i32>,
  pub afterContext: Option<i32>,
  pub initialPagination: Option<Pagination>,
  pub reindexMode: Option<ReIndexingMode>,
  pub maxConvsSearched: Option<i32>,
  pub maxConvsHit: Option<i32>,
  pub convID: Option<ConversationID>,
  pub maxNameConvs: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EmptyStruct {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchMatch {
  pub startIndex: Option<i32>,
  pub endIndex: Option<i32>,
  #[serde(rename = "match")]
  #[serde(default)]
  pub match_: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchHit {
  #[serde(default)]
  pub beforeMessages: Option<Vec<Box<UIMessage>>>,
  pub hitMessage: Option<Box<UIMessage>>,
  #[serde(default)]
  pub afterMessages: Option<Vec<Box<UIMessage>>>,
  #[serde(default)]
  pub matches: Option<Vec<ChatSearchMatch>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchInboxHit {
  pub convID: Option<ConversationID>,
  pub teamType: Option<TeamType>,
  #[serde(default)]
  pub convName: Option<String>,
  #[serde(default)]
  pub query: Option<String>,
  pub time: Option<gregor1::Time>,
  #[serde(default)]
  pub hits: Option<Vec<ChatSearchHit>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchInboxResults {
  #[serde(default)]
  pub hits: Option<Vec<ChatSearchInboxHit>>,
  pub percentIndexed: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchInboxDone {
  pub numHits: Option<i32>,
  pub numConvs: Option<i32>,
  pub percentIndexed: Option<i32>,
  #[serde(default)]
  pub delegated: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChatSearchIndexStatus {
  pub percentIndexed: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AssetMetadataImage {
  pub width: Option<i32>,
  pub height: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AssetMetadataVideo {
  pub width: Option<i32>,
  pub height: Option<i32>,
  pub durationMs: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AssetMetadataAudio {
  pub durationMs: Option<i32>,
}

// @go("nostring")
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum AssetMetadataType {
  None_0,
  Image_1,
  Video_2,
  Audio_3,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum AssetMetadata {
  Image {image: AssetMetadataImage},
  Video {video: AssetMetadataVideo},
  Audio {audio: AssetMetadataAudio},
}

// @go("nostring")
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum AssetTag {
  Primary_0,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Asset {
  #[serde(default)]
  pub filename: Option<String>,
  #[serde(default)]
  pub region: Option<String>,
  #[serde(default)]
  pub endpoint: Option<String>,
  #[serde(default)]
  pub bucket: Option<String>,
  #[serde(default)]
  pub path: Option<String>,
  pub size: Option<i64>,
  #[serde(default)]
  pub mimeType: Option<String>,
  #[serde(default)]
  pub encHash: Option<String>,
  #[serde(default)]
  pub key: Option<String>,
  #[serde(default)]
  pub verifyKey: Option<String>,
  #[serde(default)]
  pub title: Option<String>,
  #[serde(default)]
  pub nonce: Option<String>,
  pub metadata: Option<AssetMetadata>,
  pub tag: Option<AssetTag>,
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum BotCommandsAdvertisementTyp {
  Public_0,
  Tlfid_members_1,
  Tlfid_convs_2,
}