@myronsi/messenger-api 2.1.0-alpha.5.next.70 → 2.1.0-alpha.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.5. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.50. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -32,32 +32,148 @@ export type AttachmentRef = string;
32
32
  * Every event the server may send.
33
33
  */
34
34
  export type ServerEvent =
35
+ | ServerAccountStatusEvent
35
36
  | ServerAckEvent
36
37
  | ServerApprovalRequestCreatedEvent
38
+ | ServerAttachmentUpdatedEvent
39
+ | ServerCallKeysEvent
40
+ | ServerCallUpdatedEvent
37
41
  | ServerChatCreatedEvent
38
42
  | ServerChatDeletedEvent
39
43
  | ServerChatListUpdateEvent
44
+ | ServerClientSettingsUpdatedEvent
40
45
  | ServerDeleteEvent
41
46
  | ServerEditEvent
42
47
  | ServerErrorEvent
43
48
  | ServerGroupCreatedEvent
44
49
  | ServerGroupUpdatedEvent
45
50
  | ServerHelloEvent
51
+ | ServerHistoryClearedEvent
52
+ | ServerImportSenderUpdateEvent
53
+ | ServerImportUpdateEvent
46
54
  | ServerMessageEvent
55
+ | ServerPinUpdateEvent
56
+ | ServerPlaylistsUpdatedEvent
57
+ | ServerPollUpdatedEvent
47
58
  | ServerPresenceEvent
48
59
  | ServerReactionAddEvent
49
60
  | ServerReactionRemoveEvent
50
61
  | ServerReadEvent
62
+ | ServerRecoveryRequestEvent
63
+ | ServerReportOutcomeEvent
64
+ | ServerSecurityAlertEvent
51
65
  | ServerSecurityNoticeEvent
52
- | ServerTypingEvent;
66
+ | ServerTypingEvent
67
+ | ServerUserUpdatedEvent
68
+ | ServerWallpaperUpdatedEvent;
69
+ /**
70
+ * `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
71
+ * new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
72
+ * and emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).
73
+ * Unknown values must be treated like `restricted`.
74
+ *
75
+ */
76
+ export type AccountStatusLevel = "good" | "warned" | "limited" | "restricted" | "suspended";
53
77
  export type Timestamp = string;
78
+ /**
79
+ * An action the account status blocks. Unknown values must be shown as a generic restriction.
80
+ */
81
+ export type AccountRestriction =
82
+ | "start_direct"
83
+ | "invite_to_group"
84
+ | "call"
85
+ | "create_group"
86
+ | "upload"
87
+ | "forward"
88
+ | "edit_profile"
89
+ | "publish_pack"
90
+ | "search"
91
+ | "send"
92
+ | "manage_group"
93
+ | "share_group"
94
+ | "join_by_link";
95
+ /**
96
+ * Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the
97
+ * moderation team). Missing means `automatic`. Unknown values must be treated like `automatic`.
98
+ *
99
+ */
100
+ export type AccountStatusDecidedBy = "automatic" | "staff";
101
+ /**
102
+ * The guideline rule behind a moderation decision. Unknown values must be shown as `other`.
103
+ */
104
+ export type ModerationReason =
105
+ "spam" | "scam" | "harassment" | "impersonation" | "inappropriate_profile" | "illegal" | "other";
54
106
  export type ApprovalRequestType = "direct_message" | "group_invite";
55
107
  export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
108
+ export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
109
+ export type MediaProcessing = "queued" | "running" | "done" | "failed";
110
+ /**
111
+ * `media` an uploaded image, GIF or short video (`attachment`), `preset` one of the clients' built-in
112
+ * gradients (`preset`), `color` one color or a gradient of two (`colors`).
113
+ *
114
+ */
115
+ export type ProfileBackgroundKind = "media" | "preset" | "color";
116
+ /**
117
+ * Name of a built-in gradient. Clients show their default background for a name they do not know.
118
+ */
119
+ export type BackgroundPreset = string;
120
+ export type BackgroundColor = string;
56
121
  export type Username = string;
122
+ export type AccountLabel = "restricted";
123
+ /**
124
+ * `ringing` until someone answers, `active` while people are in it, `ended` afterwards.
125
+ */
126
+ export type CallState = "ringing" | "active" | "ended";
127
+ /**
128
+ * Why the call ended: `completed` (people talked), `missed` (nobody answered in time), `declined` (the peer of a
129
+ * direct call declined), `cancelled` (the caller hung up before an answer), `failed` (the media service lost
130
+ * the call).
131
+ *
132
+ */
133
+ export type CallEndReason = "completed" | "missed" | "declined" | "cancelled" | "failed";
134
+ /**
135
+ * `left` and `declined` can become `joined` again in a group call.
136
+ */
137
+ export type CallParticipantState = "ringing" | "joined" | "declined" | "missed" | "left";
138
+ /**
139
+ * P-256 public key as an uncompressed point (65 bytes, first byte `0x04`), base64url without padding.
140
+ *
141
+ */
142
+ export type CallIdentityKey = string;
57
143
  export type ChatType = "direct" | "group";
58
- export type MessageType = "text" | "file" | "voice" | "system";
59
- export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
60
- export type GroupRole = "owner" | "admin" | "member";
144
+ /**
145
+ * `poll`, `contact` and `location` carry their data in `Message.poll`, `Message.contact` and
146
+ * `Message.location`. For older clients their `content` holds a short plain-text summary: `📊 <question>`,
147
+ * `👤 @<username>`, or `📍 <place name> <OpenStreetMap link>`.
148
+ *
149
+ */
150
+ export type MessageType = "text" | "file" | "voice" | "system" | "sticker" | "poll" | "contact" | "location";
151
+ export type StickerPackSlug = string;
152
+ export type ImportSource = "telegram" | "whatsapp";
153
+ export type SystemEventKind =
154
+ | "group_created"
155
+ | "member_added"
156
+ | "member_joined"
157
+ | "member_removed"
158
+ | "member_left"
159
+ | "call"
160
+ | "message_pinned"
161
+ | "message_unpinned"
162
+ | "history_imported"
163
+ | "history_import_ended"
164
+ | "imported_note"
165
+ | "group_renamed"
166
+ | "group_avatar_changed"
167
+ | "owner_transferred"
168
+ | "chat_wallpaper_set";
169
+ /**
170
+ * A moderator may delete other members' messages; owners and admins also manage the group.
171
+ */
172
+ export type GroupRole = "owner" | "admin" | "moderator" | "member";
173
+ /**
174
+ * A Unicode emoji or a custom emoji token, exactly as the client inserts it.
175
+ */
176
+ export type RecentEmoji = string;
61
177
  /**
62
178
  * Stable machine-readable error code. New codes can appear in MINOR versions; unknown
63
179
  * codes must be treated like `internal_error`.
@@ -79,10 +195,63 @@ export type ErrorCode =
79
195
  | "unsupported_media_type"
80
196
  | "rate_limited"
81
197
  | "client_outdated"
198
+ | "device_proof_stale"
82
199
  | "invalid_client_version"
83
200
  | "blocked_by_user"
84
201
  | "approval_required"
202
+ | "user_verification_required"
203
+ | "session_too_new"
204
+ | "calls_unavailable"
205
+ | "calls_not_allowed"
206
+ | "call_identity_required"
207
+ | "call_full"
208
+ | "call_ended"
209
+ | "already_in_call"
210
+ | "stale_epoch"
211
+ | "limit_reached"
212
+ | "account_restricted"
213
+ | "poll_closed"
214
+ | "quiz_answered"
85
215
  | "internal_error";
216
+ /**
217
+ * A username or a group's public name. One name space for both, unique ignoring case; links are `/@name` on the
218
+ * web app's origin.
219
+ *
220
+ */
221
+ export type PublicName = string;
222
+ /**
223
+ * The client's key for one name of the export.
224
+ */
225
+ export type ImportSenderKey = string;
226
+ /**
227
+ * `me`: the importer's own messages. `unassigned`: shown as text. `pending`: suggested for `user_id`, who has
228
+ * not answered. `confirmed`: `user_id` confirmed; the messages show their account. `declined`: the suggested
229
+ * member said no; shown as text.
230
+ *
231
+ */
232
+ export type ImportSenderState = "me" | "unassigned" | "pending" | "confirmed" | "declined";
233
+ /**
234
+ * `running`: messages are being added. `done`: finished. `removing`: being removed.
235
+ */
236
+ export type ChatImportState = "running" | "done" | "removing";
237
+ /**
238
+ * `me`: only for the caller. `everyone`: for every member of the chat.
239
+ */
240
+ export type PinScope = "me" | "everyone";
241
+ /**
242
+ * What was reported. Unknown values must be shown without the subject.
243
+ */
244
+ export type ReportSubjectType = "user" | "sticker_pack" | "emoji_pack";
245
+ /**
246
+ * `action_taken` the moderation team acted on the report, `no_violation` it found no violation. Unknown values
247
+ * must be shown as a generic "your report was reviewed".
248
+ *
249
+ */
250
+ export type ReportOutcomeKind = "action_taken" | "no_violation";
251
+ /**
252
+ * Dots or a grid drawn over a `color` background.
253
+ */
254
+ export type WallpaperPattern = "none" | "dots" | "grid";
86
255
 
87
256
  /**
88
257
  * Delete a message for yourself or for everyone.
@@ -143,6 +312,9 @@ export interface ClientReactionAddEvent {
143
312
  chat_id: Id;
144
313
  data: {
145
314
  message_id: Id;
315
+ /**
316
+ * A Unicode emoji, or c:<id> for a custom emoji the user may use (custom ones are only checked when added).
317
+ */
146
318
  emoji: string;
147
319
  };
148
320
  }
@@ -155,6 +327,9 @@ export interface ClientReactionRemoveEvent {
155
327
  chat_id: Id;
156
328
  data: {
157
329
  message_id: Id;
330
+ /**
331
+ * A Unicode emoji, or c:<id> for a custom emoji the user may use (custom ones are only checked when added).
332
+ */
158
333
  emoji: string;
159
334
  };
160
335
  }
@@ -181,15 +356,63 @@ export interface ClientResendEvent {
181
356
  };
182
357
  }
183
358
  /**
184
- * Tell the chat that you are (not) typing. Not acknowledged, so it carries no `client_temp_id`.
359
+ * Tell the chat that you are (not) typing, recording a voice message, choosing a sticker or sending a photo, video or file. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.
185
360
  */
186
361
  export interface ClientTypingEvent {
187
362
  type: "typing";
188
363
  chat_id: Id;
189
364
  data: {
190
365
  is_typing: boolean;
366
+ /**
367
+ * What you are doing. Without it, `typing`.
368
+ */
369
+ action?:
370
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
191
371
  };
192
372
  }
373
+ /**
374
+ * The current user's account status changed (sent only to the user's own sessions).
375
+ */
376
+ export interface ServerAccountStatusEvent {
377
+ type: "account_status";
378
+ event_id: Id;
379
+ chat_id: null;
380
+ data: AccountStatus;
381
+ }
382
+ export interface AccountStatus {
383
+ status: AccountStatusLevel;
384
+ /**
385
+ * When the account reached this status; `null` when it never changed.
386
+ */
387
+ since: Timestamp | null;
388
+ restrictions: AccountRestriction[];
389
+ can_appeal: boolean;
390
+ /**
391
+ * End of the running probation after an appeal; `null` when none runs.
392
+ */
393
+ probation_until: Timestamp | null;
394
+ decided_by?: AccountStatusDecidedBy;
395
+ /**
396
+ * The guideline rule a person on the moderation team named; `null` for automatic statuses.
397
+ */
398
+ reason_code?: ModerationReason | null;
399
+ /**
400
+ * The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as
401
+ * written by "Messenger moderation", never by a person's name.
402
+ *
403
+ */
404
+ reason_text?: string | null;
405
+ /**
406
+ * When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when
407
+ * none is open.
408
+ *
409
+ */
410
+ review_requested_at: Timestamp | null;
411
+ /**
412
+ * Whether `POST /me/account-status/review` is allowed now.
413
+ */
414
+ can_request_review: boolean;
415
+ }
193
416
  /**
194
417
  * The server accepted the client event with this `client_temp_id`.
195
418
  */
@@ -246,6 +469,28 @@ export interface ApprovalRequest {
246
469
  */
247
470
  export interface User {
248
471
  id: Id;
472
+ /**
473
+ * Grows whenever the username, display name, bio, avatar, pronouns, birthday, profile music or profile
474
+ * background changes (not with presence). Clients keep a stored profile until a higher version arrives.
475
+ *
476
+ */
477
+ profile_version: number;
478
+ /**
479
+ * Free text such as "she/her". Visible like the bio (`profile_visibility`).
480
+ */
481
+ pronouns: string | null;
482
+ /**
483
+ * Visible by `birthday_visibility`; `null` when not set or hidden.
484
+ */
485
+ birthday: Birthday | null;
486
+ /**
487
+ * A short song on the profile, visible like the bio. Clients never play it on their own.
488
+ */
489
+ music: ProfileMusic | null;
490
+ /**
491
+ * The banner and page background of the profile, visible like the bio.
492
+ */
493
+ background: ProfileBackground | null;
249
494
  username: Username;
250
495
  display_name: string;
251
496
  /**
@@ -260,6 +505,259 @@ export interface User {
260
505
  is_online: boolean;
261
506
  last_seen: Timestamp | null;
262
507
  is_deleted: boolean;
508
+ /**
509
+ * Only on `Chat.peer` of a direct chat: whether the requesting user may send this user voice messages and
510
+ * videos (their `voice_video_messages` setting and exceptions). Absent everywhere else.
511
+ *
512
+ */
513
+ can_send_voice_video?: boolean;
514
+ /**
515
+ * `restricted` when the account is suspended by its automatic account status; clients show "Restricted
516
+ * account". Absent otherwise.
517
+ *
518
+ */
519
+ account_label?: AccountLabel;
520
+ }
521
+ export interface Birthday {
522
+ day: number;
523
+ month: number;
524
+ /**
525
+ * Optional; `null` when the user keeps the year to themselves.
526
+ */
527
+ year: number | null;
528
+ }
529
+ export interface ProfileMusic {
530
+ /**
531
+ * The clip (at most 30 s). `thumbnail_url` is the cover when the file had one.
532
+ */
533
+ attachment: Attachment;
534
+ title: string | null;
535
+ artist: string | null;
536
+ }
537
+ export interface Attachment {
538
+ id: AttachmentRef;
539
+ kind: AttachmentKind;
540
+ filename: string;
541
+ /**
542
+ * Detected by the server
543
+ */
544
+ content_type: string;
545
+ /**
546
+ * Bytes
547
+ */
548
+ size: number;
549
+ /**
550
+ * Same-origin path (`/api/v2/attachments/{id}/content`) set by the server.
551
+ */
552
+ url: string;
553
+ width?: number | null;
554
+ height?: number | null;
555
+ /**
556
+ * A WebP of at most 480 px (older uploads a JPEG of at most 320 px); for audio the embedded cover.
557
+ */
558
+ thumbnail_url?: string | null;
559
+ /**
560
+ * At most 1600 px to show in an image viewer instead of the original; `null` for small images and GIFs, which are shown as they are.
561
+ */
562
+ display_url?: string | null;
563
+ /**
564
+ * A ThumbHash (base64) of the image or video poster, to draw a blurred preview before the thumbnail arrives.
565
+ */
566
+ placeholder?: string | null;
567
+ /**
568
+ * Whether the server is still making an optimized copy of a video, GIF or audio file. Clients play `url`
569
+ * meanwhile and swap to the new copy on `attachment_updated`. `null` when there is nothing to do.
570
+ *
571
+ */
572
+ processing?: MediaProcessing | null;
573
+ /**
574
+ * The file as uploaded, when `url` serves an optimized copy; `null` otherwise.
575
+ */
576
+ source_url?: string | null;
577
+ /**
578
+ * A GIF as a muted, looping MP4, much smaller than the GIF; `null` until made or for other files.
579
+ */
580
+ animation_url?: string | null;
581
+ /**
582
+ * Stickers only; a still 128 px WebP for pickers and lists.
583
+ */
584
+ panel_url?: string | null;
585
+ /**
586
+ * Stickers only; a 320 px WebP for messages.
587
+ */
588
+ message_url?: string | null;
589
+ duration_ms?: number | null;
590
+ waveform?: number[] | null;
591
+ tags?: AudioTags;
592
+ drawing?: Drawing;
593
+ }
594
+ /**
595
+ * Audio files (not voice messages) and `profile_music` uploads; what the file says about itself.
596
+ */
597
+ export interface AudioTags {
598
+ title: string | null;
599
+ artist: string | null;
600
+ album?: string | null;
601
+ }
602
+ /**
603
+ * What the sender drew on this image of this message. Clients show the image with the drawing on top
604
+ * and never without it. Absent when the image has no drawing. The same image can carry another drawing
605
+ * in another message.
606
+ *
607
+ */
608
+ export interface Drawing {
609
+ version: number;
610
+ /**
611
+ * @minItems 1
612
+ * @maxItems 200
613
+ */
614
+ items: [DrawingItem, ...DrawingItem[]];
615
+ }
616
+ export interface DrawingItem {
617
+ type: "stroke" | "text";
618
+ color: string;
619
+ /**
620
+ * Stroke only. Line width as a fraction of the image width.
621
+ */
622
+ width?: number;
623
+ /**
624
+ * Stroke only. Flat list of x, y pairs. A drawing has at most 10000 numbers in all its strokes.
625
+ *
626
+ * @minItems 2
627
+ * @maxItems 10000
628
+ */
629
+ points?: [number, number, ...number[]];
630
+ /**
631
+ * Text only. Left edge of the label.
632
+ */
633
+ x?: number;
634
+ /**
635
+ * Text only. Top edge of the label.
636
+ */
637
+ y?: number;
638
+ /**
639
+ * Text only. Font height as a fraction of the image height.
640
+ */
641
+ size?: number;
642
+ /**
643
+ * Text only.
644
+ */
645
+ text?: string;
646
+ }
647
+ export interface ProfileBackground {
648
+ kind: ProfileBackgroundKind;
649
+ /**
650
+ * Set for `media`. An image, an animated GIF or a muted video of at most 15 s; `thumbnail_url` is a still
651
+ * frame to show while it loads and when the viewer prefers reduced motion.
652
+ *
653
+ */
654
+ attachment?: Attachment;
655
+ preset?: BackgroundPreset;
656
+ /**
657
+ * @minItems 1
658
+ * @maxItems 2
659
+ */
660
+ colors?: [BackgroundColor] | [BackgroundColor, BackgroundColor];
661
+ }
662
+ /**
663
+ * The server finished (or gave up) making an optimized copy of an attachment you can see: a video or audio file now served as H.264/AAC, or a GIF with an animation_url. Replace the attachment in every message that holds it; a playing media element keeps its position.
664
+ */
665
+ export interface ServerAttachmentUpdatedEvent {
666
+ type: "attachment_updated";
667
+ event_id: Id;
668
+ chat_id: null;
669
+ data: {
670
+ attachment: Attachment;
671
+ };
672
+ }
673
+ /**
674
+ * Sealed sender keys for this session (see docs/calls-e2ee.md). Sent only to the recipient session.
675
+ */
676
+ export interface ServerCallKeysEvent {
677
+ type: "call_keys";
678
+ event_id: Id;
679
+ chat_id: Id;
680
+ data: CallKeyEnvelopeList;
681
+ }
682
+ export interface CallKeyEnvelopeList {
683
+ call_id: Id;
684
+ epoch: number;
685
+ items: CallKeyEnvelope[];
686
+ }
687
+ /**
688
+ * An HPKE Auth-mode envelope carrying one sender key (see `docs/calls-e2ee.md`).
689
+ */
690
+ export interface CallKeyEnvelope {
691
+ epoch: number;
692
+ sender_user_id: Id;
693
+ sender_session_id: string;
694
+ recipient_session_id: string;
695
+ /**
696
+ * HPKE encapsulated key, base64url without padding.
697
+ */
698
+ enc: string;
699
+ /**
700
+ * Sealed sender key, base64url without padding.
701
+ */
702
+ ciphertext: string;
703
+ }
704
+ /**
705
+ * A call of the chat started, rang, changed participants or epoch, or ended. Carries the whole call; keep the one with the highest `version`. Sent to every member of the chat.
706
+ */
707
+ export interface ServerCallUpdatedEvent {
708
+ type: "call_updated";
709
+ event_id: Id;
710
+ chat_id: Id;
711
+ data: {
712
+ call: Call;
713
+ };
714
+ }
715
+ export interface Call {
716
+ id: Id;
717
+ chat_id: Id;
718
+ kind: "direct" | "group";
719
+ state: CallState;
720
+ end_reason: CallEndReason | null;
721
+ initiator_id: Id;
722
+ created_at: Timestamp;
723
+ /**
724
+ * First answer; `null` while nobody answered.
725
+ */
726
+ started_at: Timestamp | null;
727
+ ended_at: Timestamp | null;
728
+ /**
729
+ * When ringing invitations of this call turn into `missed`.
730
+ */
731
+ ring_expires_at: string;
732
+ /**
733
+ * Key epoch; increases whenever the set of joined sessions or their identity keys change.
734
+ */
735
+ epoch: number;
736
+ /**
737
+ * Increases with every change of the call; ignore events with a lower version than one already seen.
738
+ */
739
+ version: number;
740
+ max_participants: number;
741
+ /**
742
+ * Everyone invited or joined, the initiator first.
743
+ */
744
+ participants: CallParticipant[];
745
+ }
746
+ export interface CallParticipant {
747
+ user_id: Id;
748
+ state: CallParticipantState;
749
+ /**
750
+ * The session that joined; `null` unless `state` is `joined`.
751
+ */
752
+ session_id: string | null;
753
+ /**
754
+ * Call identity of the joined session; `null` unless `state` is `joined`.
755
+ */
756
+ identity_key: CallIdentityKey | null;
757
+ /**
758
+ * When the participant last joined; `null` if never.
759
+ */
760
+ joined_at: Timestamp | null;
263
761
  }
264
762
  /**
265
763
  * A chat was created with you.
@@ -281,16 +779,51 @@ export interface Chat {
281
779
  name: string;
282
780
  avatar_url: string | null;
283
781
  /**
284
- * The other user of a direct chat; `null` for groups.
782
+ * The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
285
783
  */
286
784
  peer: User | null;
287
785
  is_pinned: boolean;
786
+ /**
787
+ * Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
788
+ */
789
+ pin_position: number | null;
790
+ /**
791
+ * Whether the caller archived the chat (only for the caller).
792
+ */
793
+ is_archived: boolean;
794
+ /**
795
+ * Whether the chat is in the caller's Requests folder: a stranger opened it, and the caller has not
796
+ * replied, accepted, pinned or archived it yet (only for the caller).
797
+ *
798
+ */
799
+ is_request: boolean;
288
800
  unread_count: number;
801
+ /**
802
+ * Unread messages that mention the caller (`GET /chats/{chat_id}/mentions`). Clients show an `@` badge while
803
+ * it is above 0. Always 0 in direct chats.
804
+ *
805
+ */
806
+ unread_mentions_count: number;
807
+ /**
808
+ * The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
809
+ * not system messages, not deleted); `null` when nothing is unread. Clients open the chat around it and
810
+ * show the "new messages" divider above it.
811
+ *
812
+ */
813
+ first_unread_message_id: Id | null;
814
+ /**
815
+ * The caller's read marker (`POST /chats/{chat_id}/read`); `null` before their first read.
816
+ */
817
+ last_read_message_id: Id | null;
289
818
  last_message: Message | null;
290
819
  /**
291
820
  * Only for groups.
292
821
  */
293
822
  my_role?: GroupRole | null;
823
+ /**
824
+ * Pinned messages the caller sees (`GET /chats/{chat_id}/pins`); clients show the pinned bar above 0.
825
+ */
826
+ pinned_message_count: number;
294
827
  created_at: Timestamp;
295
828
  }
296
829
  export interface Message {
@@ -302,47 +835,158 @@ export interface Message {
302
835
  */
303
836
  sender: User | null;
304
837
  /**
305
- * Text, or the caption of a file; `null` when deleted.
838
+ * Text, the caption of a file, the emoji of a sticker, or the plain-text summary of a poll, contact or
839
+ * location (see `MessageType`); `null` when deleted.
840
+ *
306
841
  */
307
842
  content: string | null;
308
843
  attachment: Attachment | null;
309
844
  reply_to: Id | null;
845
+ reply_preview?: ReplyPreview;
310
846
  forwarded_from: ForwardedFrom | null;
847
+ sticker?: Sticker;
848
+ /**
849
+ * Ordered images and videos of an album. The first item is also returned as attachment for older clients.
850
+ *
851
+ * @minItems 2
852
+ * @maxItems 10
853
+ */
854
+ attachments?:
855
+ | [Attachment, Attachment]
856
+ | [Attachment, Attachment, Attachment]
857
+ | [Attachment, Attachment, Attachment, Attachment]
858
+ | [Attachment, Attachment, Attachment, Attachment, Attachment]
859
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
860
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
861
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
862
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
863
+ | [
864
+ Attachment,
865
+ Attachment,
866
+ Attachment,
867
+ Attachment,
868
+ Attachment,
869
+ Attachment,
870
+ Attachment,
871
+ Attachment,
872
+ Attachment,
873
+ Attachment
874
+ ];
311
875
  reactions: Reaction[];
312
876
  read_by: ReadReceipt[];
877
+ /**
878
+ * When the message was sent; for an imported message, when it was sent in the other messenger.
879
+ */
313
880
  created_at: Timestamp;
314
881
  edited_at: Timestamp | null;
315
882
  is_deleted: boolean;
883
+ import?: MessageImport;
884
+ /**
885
+ * `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
886
+ * moderation" instead of the deleted placeholder. Absent otherwise.
887
+ *
888
+ */
889
+ removed_by_moderation?: boolean;
890
+ /**
891
+ * Why moderation removed the message; only for its sender, absent for everyone else.
892
+ */
893
+ moderation_reason?: ModerationRemovalReason;
894
+ system_event?: SystemEvent;
316
895
  client_temp_id?: ClientTempId;
317
- }
318
- export interface Attachment {
319
- id: AttachmentRef;
320
- kind: AttachmentKind;
321
- filename: string;
322
896
  /**
323
- * Detected by the server
897
+ * Group members the text mentions by `@username` (ignoring case), found by the server when the message was
898
+ * sent or last edited; at most 20. Absent when there are none and in direct chats. Clients render every
899
+ * `@name` token as a link to `/@name`; these IDs only decide highlighting and notifications.
900
+ *
901
+ *
902
+ * @maxItems 20
324
903
  */
325
- content_type: string;
904
+ mentions?:
905
+ | []
906
+ | [Id]
907
+ | [Id, Id]
908
+ | [Id, Id, Id]
909
+ | [Id, Id, Id, Id]
910
+ | [Id, Id, Id, Id, Id]
911
+ | [Id, Id, Id, Id, Id, Id]
912
+ | [Id, Id, Id, Id, Id, Id, Id]
913
+ | [Id, Id, Id, Id, Id, Id, Id, Id]
914
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id]
915
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
916
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
917
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
918
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
919
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
920
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
921
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
922
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
923
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
924
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id]
925
+ | [Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id, Id];
326
926
  /**
327
- * Bytes
927
+ * `true` when an owner or admin wrote `@all`; it mentions every member. Absent otherwise.
328
928
  */
329
- size: number;
929
+ mentions_all?: boolean;
930
+ poll?: Poll;
931
+ contact?: ContactCard;
932
+ location?: MessageLocation;
933
+ }
934
+ /**
935
+ * What a reply shows of the message it answers, so a client can draw the quote without loading that
936
+ * message. Set on messages of history pages and `message` events when the recipient can see the answered
937
+ * message; absent when it is gone or hidden for them, and on chat-list previews and search results.
938
+ *
939
+ */
940
+ export interface ReplyPreview {
941
+ id: Id;
942
+ type: MessageType;
943
+ sender: User | null;
330
944
  /**
331
- * Same-origin path (`/api/v2/attachments/{id}/content`) set by the server.
945
+ * The first 100 characters of the text or caption; `null` when deleted or empty.
332
946
  */
333
- url: string;
334
- width?: number | null;
335
- height?: number | null;
336
- thumbnail_url?: string | null;
337
- duration_ms?: number | null;
338
- waveform?: number[] | null;
947
+ content: string | null;
948
+ attachment: Attachment | null;
949
+ is_deleted: boolean;
950
+ /**
951
+ * `true` when moderation removed the answered message. Absent otherwise.
952
+ */
953
+ removed_by_moderation?: boolean;
339
954
  }
340
955
  export interface ForwardedFrom {
341
956
  message_id: Id;
957
+ /**
958
+ * The original sender; `null` when their account is gone or their `forward_link` setting hides it from the
959
+ * requesting user. Clients then show `sender_name` as plain text, not as a link to a profile.
960
+ *
961
+ */
342
962
  sender_id: Id | null;
343
963
  sender_name: string;
344
964
  }
965
+ /**
966
+ * The sticker of a `sticker` message; absent for other types and when deleted. `attachment` carries the
967
+ * same image, so older clients show a sticker as a picture.
968
+ *
969
+ */
970
+ export interface Sticker {
971
+ id: Id;
972
+ pack_id: Id;
973
+ /**
974
+ * The share link of the sticker's pack when a user made it; missing for built-in packs. A client that
975
+ * shows the pack of a sticker someone sent opens it with `GET /stickers/links/{slug}`.
976
+ *
977
+ */
978
+ pack_slug?: StickerPackSlug;
979
+ /**
980
+ * The emoji the sticker stands for, for previews, notifications and search.
981
+ */
982
+ emoji: string;
983
+ is_animated: boolean;
984
+ image: Attachment;
985
+ }
345
986
  export interface Reaction {
987
+ /**
988
+ * A Unicode emoji, or `c:<id>` for a custom emoji (`GET /emoji/items/{id}/image`).
989
+ */
346
990
  emoji: string;
347
991
  user_id: Id;
348
992
  }
@@ -350,6 +994,169 @@ export interface ReadReceipt {
350
994
  user_id: Id;
351
995
  read_at: Timestamp;
352
996
  }
997
+ /**
998
+ * Set on messages that came from an import.
999
+ */
1000
+ export interface MessageImport {
1001
+ import_id: Id;
1002
+ source: ImportSource;
1003
+ original_at: Timestamp;
1004
+ /**
1005
+ * The name in the export; absent on system messages.
1006
+ */
1007
+ sender_name?: string;
1008
+ /**
1009
+ * `me`: the importer's own message, `sender` is the importer. `confirmed`: the member confirmed the name,
1010
+ * `sender` is that member. `unconfirmed`: `sender` is `null`; show `sender_name` as text. Absent on system
1011
+ * messages.
1012
+ *
1013
+ */
1014
+ sender_state?: "me" | "confirmed" | "unconfirmed";
1015
+ }
1016
+ /**
1017
+ * Why moderation removed something, shown only to its author.
1018
+ */
1019
+ export interface ModerationRemovalReason {
1020
+ code: ModerationReason;
1021
+ /**
1022
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
1023
+ * never by a person's name.
1024
+ *
1025
+ */
1026
+ text: string;
1027
+ }
1028
+ /**
1029
+ * What a `system` message records; set on system messages only, whose `content` is then `null`. The names
1030
+ * are the display names at the time of the event. `target` fields are set for `member_added`,
1031
+ * `member_removed` and `owner_transferred` (the new owner; `actor` is the previous one). `call` is set for
1032
+ * `call` messages: one per call, posted when the call ends, `actor` is the initiator. `message_id` and
1033
+ * `snippet` are set for `message_pinned` and `message_unpinned`. `old_name` and `new_name` are set for
1034
+ * `group_renamed`, `avatar_removed` for `group_avatar_changed`. `chat_wallpaper_set`: `actor` set a background
1035
+ * for both people of a direct chat.
1036
+ * `history_imported` opens and `history_import_ended` closes an imported history; both carry `import`, and
1037
+ * `actor` is the importer. `imported_note` is a line of the export that is not a message; its text is `text`.
1038
+ *
1039
+ */
1040
+ export interface SystemEvent {
1041
+ kind: SystemEventKind;
1042
+ actor_id: Id | null;
1043
+ actor_name: string;
1044
+ target_id?: Id;
1045
+ target_name?: string;
1046
+ call?: CallSummary;
1047
+ /**
1048
+ * The pinned or unpinned message.
1049
+ */
1050
+ message_id?: Id;
1051
+ /**
1052
+ * Start of the pinned message's text at the time of the event (at most 60 characters plus `…`): the question
1053
+ * of a poll, the place name of a location. Empty for a message without text and for a contact, which clients
1054
+ * name by its `message_type`.
1055
+ *
1056
+ */
1057
+ snippet?: string;
1058
+ message_type?: MessageType;
1059
+ old_name?: string;
1060
+ new_name?: string;
1061
+ /**
1062
+ * `true` when the group photo was removed, `false` when a new one was set.
1063
+ */
1064
+ avatar_removed?: boolean;
1065
+ import?: ImportSummary;
1066
+ /**
1067
+ * The line of the export, for `imported_note`.
1068
+ */
1069
+ text?: string;
1070
+ }
1071
+ /**
1072
+ * The call a `call` system message records.
1073
+ */
1074
+ export interface CallSummary {
1075
+ call_id: Id;
1076
+ kind: "direct" | "group";
1077
+ outcome: CallEndReason;
1078
+ /**
1079
+ * From the first answer to the end; `null` if nobody answered.
1080
+ */
1081
+ duration_seconds: number | null;
1082
+ }
1083
+ export interface ImportSummary {
1084
+ import_id: Id;
1085
+ source: ImportSource;
1086
+ message_count: number;
1087
+ first_at: Timestamp;
1088
+ last_at: Timestamp;
1089
+ }
1090
+ /**
1091
+ * The poll of a `poll` message as the requesting user sees it; absent for other types, when deleted and in chat-list previews.
1092
+ */
1093
+ export interface Poll {
1094
+ question: string;
1095
+ options: PollOption[];
1096
+ multiple_answers: boolean;
1097
+ anonymous: boolean;
1098
+ quiz: boolean;
1099
+ /**
1100
+ * The explanation of a quiz once the user sees the results.
1101
+ */
1102
+ explanation: string | null;
1103
+ close_at: Timestamp | null;
1104
+ closed_at: Timestamp | null;
1105
+ /**
1106
+ * People who voted, each counted once even with several answers.
1107
+ */
1108
+ total_voters: number | null;
1109
+ /**
1110
+ * Indexes of the options the user voted for; empty when they have not voted.
1111
+ */
1112
+ my_votes: number[];
1113
+ /**
1114
+ * The user may close the poll now.
1115
+ */
1116
+ can_close: boolean;
1117
+ /**
1118
+ * Grows with every vote and when the poll closes; keep the poll with the highest version.
1119
+ */
1120
+ version: number;
1121
+ }
1122
+ export interface PollOption {
1123
+ text: string;
1124
+ voter_count: number | null;
1125
+ /**
1126
+ * Set on every option of a quiz once the user sees the results; absent otherwise.
1127
+ */
1128
+ is_correct?: boolean;
1129
+ }
1130
+ /**
1131
+ * The shared user of a `contact` message; absent for other types, when deleted and in chat-list previews.
1132
+ */
1133
+ export interface ContactCard {
1134
+ user_id: Id;
1135
+ /**
1136
+ * The shared user as the requesting user may see them now, not as they were when the card was sent; `null`
1137
+ * when the account is gone.
1138
+ *
1139
+ */
1140
+ user: User | null;
1141
+ }
1142
+ /**
1143
+ * The place of a `location` message; absent for other types and when deleted.
1144
+ */
1145
+ export interface MessageLocation {
1146
+ latitude: number;
1147
+ longitude: number;
1148
+ accuracy_m: number | null;
1149
+ title: string | null;
1150
+ map: MapImage;
1151
+ }
1152
+ export interface MapImage {
1153
+ /**
1154
+ * `GET /maps/static` with the signed point; load it like other API images
1155
+ */
1156
+ url: string;
1157
+ width: number;
1158
+ height: number;
1159
+ }
353
1160
  /**
354
1161
  * A chat was deleted, or you were removed from it.
355
1162
  */
@@ -360,7 +1167,7 @@ export interface ServerChatDeletedEvent {
360
1167
  data: {};
361
1168
  }
362
1169
  /**
363
- * The chat-list entry changed (last message, unread count, pin).
1170
+ * The chat-list entry changed (last message, unread count, pin, archive, leaving the Requests folder).
364
1171
  */
365
1172
  export interface ServerChatListUpdateEvent {
366
1173
  type: "chat_list_update";
@@ -371,7 +1178,59 @@ export interface ServerChatListUpdateEvent {
371
1178
  };
372
1179
  }
373
1180
  /**
374
- * A message was deleted for everyone (deleting for yourself is only sent to your other devices).
1181
+ * The synced settings changed on one of your devices (sent only to your own sessions).
1182
+ */
1183
+ export interface ServerClientSettingsUpdatedEvent {
1184
+ type: "client_settings_updated";
1185
+ event_id: Id;
1186
+ chat_id: null;
1187
+ data: ClientSettings;
1188
+ }
1189
+ export interface ClientSettings {
1190
+ appearance: AppearanceSettings | null;
1191
+ /**
1192
+ * Newest first.
1193
+ *
1194
+ * @maxItems 24
1195
+ */
1196
+ recent_emoji: RecentEmoji[];
1197
+ /**
1198
+ * Newest first.
1199
+ *
1200
+ * @maxItems 8
1201
+ */
1202
+ recent_reactions:
1203
+ | []
1204
+ | [RecentEmoji]
1205
+ | [RecentEmoji, RecentEmoji]
1206
+ | [RecentEmoji, RecentEmoji, RecentEmoji]
1207
+ | [RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji]
1208
+ | [RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji]
1209
+ | [RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji]
1210
+ | [RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji]
1211
+ | [RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji, RecentEmoji];
1212
+ /**
1213
+ * Goes up on every change; `0` when nothing was saved yet.
1214
+ */
1215
+ version: number;
1216
+ updated_at: Timestamp | null;
1217
+ }
1218
+ /**
1219
+ * The look of the app shared by the user's devices. A device may keep its own value for any field ("only on
1220
+ * this device"); that choice is stored on the device, not here.
1221
+ *
1222
+ */
1223
+ export interface AppearanceSettings {
1224
+ /**
1225
+ * Name of a client accent color. Clients use their default for a name they do not know.
1226
+ */
1227
+ accent: string;
1228
+ font_size: number;
1229
+ density: "comfortable" | "compact";
1230
+ corners: "sharp" | "default" | "round";
1231
+ }
1232
+ /**
1233
+ * A message was deleted for everyone (deleting for yourself is only sent to your other devices), or removed by moderation.
375
1234
  */
376
1235
  export interface ServerDeleteEvent {
377
1236
  type: "delete";
@@ -380,8 +1239,25 @@ export interface ServerDeleteEvent {
380
1239
  data: {
381
1240
  message_id: Id;
382
1241
  scope: "me" | "everyone";
1242
+ /**
1243
+ * `true` when moderation removed the message (`scope` is then `everyone`). Absent otherwise.
1244
+ */
1245
+ removed_by_moderation?: boolean;
1246
+ moderation_reason?: ModerationRemovalReason1;
383
1247
  };
384
1248
  }
1249
+ /**
1250
+ * Why moderation removed something, shown only to its author.
1251
+ */
1252
+ export interface ModerationRemovalReason1 {
1253
+ code: ModerationReason;
1254
+ /**
1255
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
1256
+ * never by a person's name.
1257
+ *
1258
+ */
1259
+ text: string;
1260
+ }
385
1261
  /**
386
1262
  * A message was edited.
387
1263
  */
@@ -403,6 +1279,27 @@ export interface ServerErrorEvent {
403
1279
  data: {
404
1280
  code: ErrorCode;
405
1281
  message?: string;
1282
+ /**
1283
+ * An action the account status blocks. Unknown values must be shown as a generic restriction.
1284
+ */
1285
+ restriction?:
1286
+ | "start_direct"
1287
+ | "invite_to_group"
1288
+ | "call"
1289
+ | "create_group"
1290
+ | "upload"
1291
+ | "forward"
1292
+ | "edit_profile"
1293
+ | "publish_pack"
1294
+ | "search"
1295
+ | "send"
1296
+ | "manage_group"
1297
+ | "share_group"
1298
+ | "join_by_link";
1299
+ /**
1300
+ * The setting or field that caused the error, for example `voice_video_messages` for a voice message or video the recipient does not accept.
1301
+ */
1302
+ field?: string;
406
1303
  };
407
1304
  client_temp_id?: ClientTempId;
408
1305
  }
@@ -422,10 +1319,18 @@ export interface Group {
422
1319
  name: string;
423
1320
  description: string | null;
424
1321
  avatar_url: string | null;
1322
+ /**
1323
+ * The banner and page background of the group profile; set by the owner and admins.
1324
+ */
1325
+ background: ProfileBackground | null;
425
1326
  owner_id: Id;
426
1327
  my_role: GroupRole;
427
1328
  members: GroupMember[];
428
1329
  created_at: Timestamp;
1330
+ /**
1331
+ * The group's public name (`/@name`); `null` for a private group.
1332
+ */
1333
+ public_name: PublicName | null;
429
1334
  }
430
1335
  export interface GroupMember {
431
1336
  user: User;
@@ -456,6 +1361,49 @@ export interface ServerHelloEvent {
456
1361
  user_id: Id;
457
1362
  };
458
1363
  }
1364
+ /**
1365
+ * Messages of the chat up to before_message_id were cleared, for you (scope me) or for every member (scope everyone). Drop them from what you show.
1366
+ */
1367
+ export interface ServerHistoryClearedEvent {
1368
+ type: "history_cleared";
1369
+ event_id: Id;
1370
+ chat_id: Id;
1371
+ data: {
1372
+ before_message_id: Id;
1373
+ scope: "me" | "everyone";
1374
+ actor_id: Id;
1375
+ };
1376
+ }
1377
+ /**
1378
+ * A name of an imported history changed. A suggestion (pending) and a decline go only to the importer and the suggested member; that member shows the confirm banner for pending. A confirmation or its withdrawal goes to every member: render the messages of that name again (or load the chat again).
1379
+ */
1380
+ export interface ServerImportSenderUpdateEvent {
1381
+ type: "import_sender_update";
1382
+ event_id: Id;
1383
+ chat_id: Id;
1384
+ data: {
1385
+ import_id: Id;
1386
+ sender: {
1387
+ key: ImportSenderKey;
1388
+ name: string;
1389
+ message_count: number;
1390
+ state: ImportSenderState;
1391
+ user_id?: Id;
1392
+ };
1393
+ };
1394
+ }
1395
+ /**
1396
+ * An imported history of the chat started, finished or is being removed; goes to every member. On done and removing, load the chat's history again; GET /chats/{chat_id}/imports lists the imports.
1397
+ */
1398
+ export interface ServerImportUpdateEvent {
1399
+ type: "import_update";
1400
+ event_id: Id;
1401
+ chat_id: Id;
1402
+ data: {
1403
+ import_id: Id;
1404
+ state: ChatImportState;
1405
+ };
1406
+ }
459
1407
  /**
460
1408
  * A new message in a chat.
461
1409
  */
@@ -467,6 +1415,99 @@ export interface ServerMessageEvent {
467
1415
  message: Message;
468
1416
  };
469
1417
  }
1418
+ /**
1419
+ * A message was pinned or unpinned. Scope everyone goes to every member; scope me (an own pin, or a pin for everyone hidden or shown again for you) only to your own sessions. Load GET /chats/{chat_id}/pins again, or apply the change: pinned adds the message to your pins, unpinned removes it. For scope everyone, unpinned may leave your own pin of the message, so reload in that case.
1420
+ */
1421
+ export interface ServerPinUpdateEvent {
1422
+ type: "pin_update";
1423
+ event_id: Id;
1424
+ chat_id: Id;
1425
+ data: {
1426
+ message_id: Id;
1427
+ action: "pinned" | "unpinned";
1428
+ scope: PinScope;
1429
+ actor_id: Id;
1430
+ at: Timestamp;
1431
+ /**
1432
+ * Chat.pinned_message_count for the recipient after the change.
1433
+ */
1434
+ pinned_message_count?: number;
1435
+ };
1436
+ }
1437
+ /**
1438
+ * One of your playlists was created, changed or deleted on one of your devices (sent only to your own sessions).
1439
+ */
1440
+ export interface ServerPlaylistsUpdatedEvent {
1441
+ type: "playlists_updated";
1442
+ event_id: Id;
1443
+ chat_id: null;
1444
+ /**
1445
+ * `created` and `updated` carry the new summary; load the playlist with `GET /me/playlists/{playlist_id}` when its `version` is newer than your copy. `deleted` has `playlist: null`.
1446
+ */
1447
+ data: {
1448
+ action: "created" | "updated" | "deleted";
1449
+ playlist_id: Id;
1450
+ playlist: PlaylistSummary | null;
1451
+ };
1452
+ }
1453
+ export interface PlaylistSummary {
1454
+ id: Id;
1455
+ name: string;
1456
+ track_count: number;
1457
+ /**
1458
+ * Goes up on every change of the name or the tracks.
1459
+ */
1460
+ version: number;
1461
+ created_at: Timestamp;
1462
+ updated_at: Timestamp;
1463
+ }
1464
+ /**
1465
+ * Someone voted, changed or took back a vote, or the poll closed. Goes to every member of the chat, each with the poll as they see it (results only after they voted, for the creator, or once closed). Replace Message.poll when version is higher than the one you have.
1466
+ */
1467
+ export interface ServerPollUpdatedEvent {
1468
+ type: "poll_updated";
1469
+ event_id: Id;
1470
+ chat_id: Id;
1471
+ data: {
1472
+ message_id: Id;
1473
+ poll: Poll1;
1474
+ };
1475
+ }
1476
+ /**
1477
+ * A poll as the requesting user sees it. Results (`voter_count`, `total_voters`, `is_correct`, `explanation`)
1478
+ * are `null` or absent until that user voted, unless they created the poll or it is closed. A poll is closed
1479
+ * when `closed_at` is set; clients also treat it as closed once `close_at` has passed.
1480
+ *
1481
+ */
1482
+ export interface Poll1 {
1483
+ question: string;
1484
+ options: PollOption[];
1485
+ multiple_answers: boolean;
1486
+ anonymous: boolean;
1487
+ quiz: boolean;
1488
+ /**
1489
+ * The explanation of a quiz once the user sees the results.
1490
+ */
1491
+ explanation: string | null;
1492
+ close_at: Timestamp | null;
1493
+ closed_at: Timestamp | null;
1494
+ /**
1495
+ * People who voted, each counted once even with several answers.
1496
+ */
1497
+ total_voters: number | null;
1498
+ /**
1499
+ * Indexes of the options the user voted for; empty when they have not voted.
1500
+ */
1501
+ my_votes: number[];
1502
+ /**
1503
+ * The user may close the poll now.
1504
+ */
1505
+ can_close: boolean;
1506
+ /**
1507
+ * Grows with every vote and when the poll closes; keep the poll with the highest version.
1508
+ */
1509
+ version: number;
1510
+ }
470
1511
  /**
471
1512
  * A user came online or went offline, as far as their privacy settings allow.
472
1513
  */
@@ -517,6 +1558,92 @@ export interface ServerReadEvent {
517
1558
  read_at: Timestamp;
518
1559
  };
519
1560
  }
1561
+ export interface ServerRecoveryRequestEvent {
1562
+ type: "recovery_request";
1563
+ event_id: string;
1564
+ chat_id: null;
1565
+ data: {
1566
+ /**
1567
+ * Approval handle for POST /auth/recovery-requests/{requestId}/approve and /deny. It is not the requester's capability.
1568
+ */
1569
+ request_id: string;
1570
+ user_agent: string;
1571
+ location: Location | null;
1572
+ /**
1573
+ * @minItems 3
1574
+ * @maxItems 3
1575
+ */
1576
+ choices: [number, number, number];
1577
+ expires_at: string;
1578
+ };
1579
+ }
1580
+ /**
1581
+ * Approximate location of a client address, looked up in an offline GeoIP database (IP geolocation by
1582
+ * DB-IP, https://db-ip.com, CC BY 4.0). The address itself is never exposed. Each field is `null` when the
1583
+ * database does not know it; clients localise the country name from `country_code`.
1584
+ *
1585
+ */
1586
+ export interface Location {
1587
+ /**
1588
+ * City name in English
1589
+ */
1590
+ city: string | null;
1591
+ /**
1592
+ * ISO 3166-1 alpha-2 country code
1593
+ */
1594
+ country_code: string | null;
1595
+ /**
1596
+ * Country name in English
1597
+ */
1598
+ country: string | null;
1599
+ }
1600
+ /**
1601
+ * The moderation team reviewed something the current user reported (sent only to the reporter's own sessions).
1602
+ */
1603
+ export interface ServerReportOutcomeEvent {
1604
+ type: "report_outcome";
1605
+ event_id: Id;
1606
+ chat_id: null;
1607
+ data: ReportOutcome;
1608
+ }
1609
+ export interface ReportOutcome {
1610
+ id: Id;
1611
+ subject_type: ReportSubjectType;
1612
+ /**
1613
+ * The reported user, sticker pack or emoji pack.
1614
+ */
1615
+ subject_id: Id;
1616
+ outcome: ReportOutcomeKind;
1617
+ created_at: Timestamp;
1618
+ read: boolean;
1619
+ }
1620
+ export interface ServerSecurityAlertEvent {
1621
+ type: "security_alert";
1622
+ event_id: Id;
1623
+ chat_id: null;
1624
+ data: {
1625
+ type:
1626
+ | "password_changed"
1627
+ | "recovery_key_changed"
1628
+ | "2fa_enabled"
1629
+ | "2fa_disabled"
1630
+ | "passkey_added"
1631
+ | "passkey_removed"
1632
+ | "recovery_email_changed"
1633
+ | "recovery_email_removed"
1634
+ | "passkey_counter_warning"
1635
+ | "login"
1636
+ | "login_2fa"
1637
+ | "passkey_login"
1638
+ | "qr_login_approved";
1639
+ user_agent?: string;
1640
+ created_at?: string;
1641
+ /**
1642
+ * The session that made the change, when a signed-in session made it. Clients skip alerts for their own session.
1643
+ */
1644
+ session_id?: string;
1645
+ };
1646
+ }
520
1647
  export interface ServerSecurityNoticeEvent {
521
1648
  type: "security_notice";
522
1649
  event_id: Id;
@@ -526,7 +1653,7 @@ export interface ServerSecurityNoticeEvent {
526
1653
  };
527
1654
  }
528
1655
  /**
529
- * A user started or stopped typing.
1656
+ * A user started or stopped typing, recording a voice message, choosing a sticker or sending a photo, video or file. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.
530
1657
  */
531
1658
  export interface ServerTypingEvent {
532
1659
  type: "typing";
@@ -535,5 +1662,71 @@ export interface ServerTypingEvent {
535
1662
  data: {
536
1663
  user_id: Id;
537
1664
  is_typing: boolean;
1665
+ /**
1666
+ * What the user is doing. New values may be added: show an unknown one like `typing`.
1667
+ */
1668
+ action:
1669
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
1670
+ };
1671
+ }
1672
+ /**
1673
+ * A user you share a chat with changed their username, display name, bio, avatar, pronouns, birthday, profile music or profile background. Fetch GET /users/{user_id} again when profile_version is higher than the one you keep.
1674
+ */
1675
+ export interface ServerUserUpdatedEvent {
1676
+ type: "user_updated";
1677
+ event_id: Id;
1678
+ chat_id: null;
1679
+ data: {
1680
+ user_id: Id;
1681
+ profile_version: number;
1682
+ };
1683
+ }
1684
+ /**
1685
+ * One of your chat backgrounds changed, from one of your devices or because the other person of a direct chat set it for both (sent only to your own sessions).
1686
+ */
1687
+ export interface ServerWallpaperUpdatedEvent {
1688
+ type: "wallpaper_updated";
1689
+ event_id: Id;
1690
+ chat_id: null;
1691
+ /**
1692
+ * `entry` is `null` when the background was removed.
1693
+ */
1694
+ data: {
1695
+ /**
1696
+ * The chat, or `null` for the default of all chats.
1697
+ */
1698
+ chat_id: Id | null;
1699
+ entry: WallpaperEntry | null;
538
1700
  };
539
1701
  }
1702
+ export interface WallpaperEntry {
1703
+ /**
1704
+ * The chat, or `null` for the default of all chats.
1705
+ */
1706
+ chat_id: Id | null;
1707
+ wallpaper: Wallpaper;
1708
+ /**
1709
+ * Who set it; the other person when they used `for_both`.
1710
+ */
1711
+ set_by: Id;
1712
+ updated_at: Timestamp;
1713
+ }
1714
+ /**
1715
+ * `preset` a built-in background of the clients (`preset`), `color` one color or a gradient of two (`colors`,
1716
+ * optional `pattern`), `media` an uploaded photo (`attachment`) with `blur` in px and `dim` in percent. A `media`
1717
+ * background without `dim` is dimmed automatically by the client (20 % in a dark theme, none in a light one).
1718
+ *
1719
+ */
1720
+ export interface Wallpaper {
1721
+ kind: ProfileBackgroundKind;
1722
+ preset?: BackgroundPreset;
1723
+ /**
1724
+ * @minItems 1
1725
+ * @maxItems 2
1726
+ */
1727
+ colors?: [BackgroundColor] | [BackgroundColor, BackgroundColor];
1728
+ pattern?: WallpaperPattern;
1729
+ attachment?: Attachment;
1730
+ blur?: number;
1731
+ dim?: number;
1732
+ }