@myronsi/messenger-api 2.1.0-alpha.4 → 2.1.0-alpha.40

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.4. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.40. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -32,8 +32,12 @@ 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
@@ -43,21 +47,99 @@ export type ServerEvent =
43
47
  | ServerGroupCreatedEvent
44
48
  | ServerGroupUpdatedEvent
45
49
  | ServerHelloEvent
50
+ | ServerHistoryClearedEvent
46
51
  | ServerMessageEvent
47
52
  | ServerPresenceEvent
48
53
  | ServerReactionAddEvent
49
54
  | ServerReactionRemoveEvent
50
55
  | ServerReadEvent
56
+ | ServerRecoveryRequestEvent
57
+ | ServerReportOutcomeEvent
58
+ | ServerSecurityAlertEvent
51
59
  | ServerSecurityNoticeEvent
52
- | ServerTypingEvent;
60
+ | ServerTypingEvent
61
+ | ServerUserUpdatedEvent;
62
+ /**
63
+ * `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
64
+ * new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
65
+ * and emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).
66
+ * Unknown values must be treated like `restricted`.
67
+ *
68
+ */
69
+ export type AccountStatusLevel = "good" | "warned" | "limited" | "restricted" | "suspended";
53
70
  export type Timestamp = string;
71
+ /**
72
+ * An action the account status blocks. Unknown values must be shown as a generic restriction.
73
+ */
74
+ export type AccountRestriction =
75
+ | "start_direct"
76
+ | "invite_to_group"
77
+ | "call"
78
+ | "create_group"
79
+ | "upload"
80
+ | "forward"
81
+ | "edit_profile"
82
+ | "publish_pack"
83
+ | "search"
84
+ | "send"
85
+ | "manage_group";
86
+ /**
87
+ * Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the
88
+ * moderation team). Missing means `automatic`. Unknown values must be treated like `automatic`.
89
+ *
90
+ */
91
+ export type AccountStatusDecidedBy = "automatic" | "staff";
92
+ /**
93
+ * The guideline rule behind a moderation decision. Unknown values must be shown as `other`.
94
+ */
95
+ export type ModerationReason =
96
+ "spam" | "scam" | "harassment" | "impersonation" | "inappropriate_profile" | "illegal" | "other";
54
97
  export type ApprovalRequestType = "direct_message" | "group_invite";
55
98
  export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
99
+ export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
100
+ export type MediaProcessing = "queued" | "running" | "done" | "failed";
101
+ /**
102
+ * `media` an uploaded image, GIF or short video (`attachment`), `preset` one of the clients' built-in
103
+ * gradients (`preset`), `color` one color or a gradient of two (`colors`).
104
+ *
105
+ */
106
+ export type ProfileBackgroundKind = "media" | "preset" | "color";
107
+ /**
108
+ * Name of a built-in gradient. Clients show their default background for a name they do not know.
109
+ */
110
+ export type BackgroundPreset = string;
111
+ export type BackgroundColor = string;
56
112
  export type Username = string;
113
+ export type AccountLabel = "restricted";
114
+ /**
115
+ * `ringing` until someone answers, `active` while people are in it, `ended` afterwards.
116
+ */
117
+ export type CallState = "ringing" | "active" | "ended";
118
+ /**
119
+ * Why the call ended: `completed` (people talked), `missed` (nobody answered in time), `declined` (the peer of a
120
+ * direct call declined), `cancelled` (the caller hung up before an answer), `failed` (the media service lost
121
+ * the call).
122
+ *
123
+ */
124
+ export type CallEndReason = "completed" | "missed" | "declined" | "cancelled" | "failed";
125
+ /**
126
+ * `left` and `declined` can become `joined` again in a group call.
127
+ */
128
+ export type CallParticipantState = "ringing" | "joined" | "declined" | "missed" | "left";
129
+ /**
130
+ * P-256 public key as an uncompressed point (65 bytes, first byte `0x04`), base64url without padding.
131
+ *
132
+ */
133
+ export type CallIdentityKey = string;
57
134
  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";
135
+ export type MessageType = "text" | "file" | "voice" | "system" | "sticker";
136
+ export type StickerPackSlug = string;
137
+ export type SystemEventKind =
138
+ "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left" | "call";
139
+ /**
140
+ * A moderator may delete other members' messages; owners and admins also manage the group.
141
+ */
142
+ export type GroupRole = "owner" | "admin" | "moderator" | "member";
61
143
  /**
62
144
  * Stable machine-readable error code. New codes can appear in MINOR versions; unknown
63
145
  * codes must be treated like `internal_error`.
@@ -82,7 +164,28 @@ export type ErrorCode =
82
164
  | "invalid_client_version"
83
165
  | "blocked_by_user"
84
166
  | "approval_required"
167
+ | "user_verification_required"
168
+ | "session_too_new"
169
+ | "calls_unavailable"
170
+ | "calls_not_allowed"
171
+ | "call_identity_required"
172
+ | "call_full"
173
+ | "call_ended"
174
+ | "already_in_call"
175
+ | "stale_epoch"
176
+ | "limit_reached"
177
+ | "account_restricted"
85
178
  | "internal_error";
179
+ /**
180
+ * What was reported. Unknown values must be shown without the subject.
181
+ */
182
+ export type ReportSubjectType = "user" | "sticker_pack" | "emoji_pack";
183
+ /**
184
+ * `action_taken` the moderation team acted on the report, `no_violation` it found no violation. Unknown values
185
+ * must be shown as a generic "your report was reviewed".
186
+ *
187
+ */
188
+ export type ReportOutcomeKind = "action_taken" | "no_violation";
86
189
 
87
190
  /**
88
191
  * Delete a message for yourself or for everyone.
@@ -143,6 +246,9 @@ export interface ClientReactionAddEvent {
143
246
  chat_id: Id;
144
247
  data: {
145
248
  message_id: Id;
249
+ /**
250
+ * A Unicode emoji, or c:<id> for a custom emoji the user may use (custom ones are only checked when added).
251
+ */
146
252
  emoji: string;
147
253
  };
148
254
  }
@@ -155,6 +261,9 @@ export interface ClientReactionRemoveEvent {
155
261
  chat_id: Id;
156
262
  data: {
157
263
  message_id: Id;
264
+ /**
265
+ * A Unicode emoji, or c:<id> for a custom emoji the user may use (custom ones are only checked when added).
266
+ */
158
267
  emoji: string;
159
268
  };
160
269
  }
@@ -181,15 +290,63 @@ export interface ClientResendEvent {
181
290
  };
182
291
  }
183
292
  /**
184
- * Tell the chat that you are (not) typing. Not acknowledged, so it carries no `client_temp_id`.
293
+ * 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
294
  */
186
295
  export interface ClientTypingEvent {
187
296
  type: "typing";
188
297
  chat_id: Id;
189
298
  data: {
190
299
  is_typing: boolean;
300
+ /**
301
+ * What you are doing. Without it, `typing`.
302
+ */
303
+ action?:
304
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
191
305
  };
192
306
  }
307
+ /**
308
+ * The current user's account status changed (sent only to the user's own sessions).
309
+ */
310
+ export interface ServerAccountStatusEvent {
311
+ type: "account_status";
312
+ event_id: Id;
313
+ chat_id: null;
314
+ data: AccountStatus;
315
+ }
316
+ export interface AccountStatus {
317
+ status: AccountStatusLevel;
318
+ /**
319
+ * When the account reached this status; `null` when it never changed.
320
+ */
321
+ since: Timestamp | null;
322
+ restrictions: AccountRestriction[];
323
+ can_appeal: boolean;
324
+ /**
325
+ * End of the running probation after an appeal; `null` when none runs.
326
+ */
327
+ probation_until: Timestamp | null;
328
+ decided_by?: AccountStatusDecidedBy;
329
+ /**
330
+ * The guideline rule a person on the moderation team named; `null` for automatic statuses.
331
+ */
332
+ reason_code?: ModerationReason | null;
333
+ /**
334
+ * The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as
335
+ * written by "Messenger moderation", never by a person's name.
336
+ *
337
+ */
338
+ reason_text?: string | null;
339
+ /**
340
+ * When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when
341
+ * none is open.
342
+ *
343
+ */
344
+ review_requested_at: Timestamp | null;
345
+ /**
346
+ * Whether `POST /me/account-status/review` is allowed now.
347
+ */
348
+ can_request_review: boolean;
349
+ }
193
350
  /**
194
351
  * The server accepted the client event with this `client_temp_id`.
195
352
  */
@@ -246,6 +403,28 @@ export interface ApprovalRequest {
246
403
  */
247
404
  export interface User {
248
405
  id: Id;
406
+ /**
407
+ * Grows whenever the username, display name, bio, avatar, pronouns, birthday, profile music or profile
408
+ * background changes (not with presence). Clients keep a stored profile until a higher version arrives.
409
+ *
410
+ */
411
+ profile_version: number;
412
+ /**
413
+ * Free text such as "she/her". Visible like the bio (`profile_visibility`).
414
+ */
415
+ pronouns: string | null;
416
+ /**
417
+ * Visible by `birthday_visibility`; `null` when not set or hidden.
418
+ */
419
+ birthday: Birthday | null;
420
+ /**
421
+ * A short song on the profile, visible like the bio. Clients never play it on their own.
422
+ */
423
+ music: ProfileMusic | null;
424
+ /**
425
+ * The banner and page background of the profile, visible like the bio.
426
+ */
427
+ background: ProfileBackground | null;
249
428
  username: Username;
250
429
  display_name: string;
251
430
  /**
@@ -253,13 +432,266 @@ export interface User {
253
432
  */
254
433
  contact_name?: string | null;
255
434
  /**
256
- * Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar`).
435
+ * Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar?rev={revision}`).
257
436
  */
258
437
  avatar_url: string | null;
259
438
  bio: string | null;
260
439
  is_online: boolean;
261
440
  last_seen: Timestamp | null;
262
441
  is_deleted: boolean;
442
+ /**
443
+ * Only on `Chat.peer` of a direct chat: whether the requesting user may send this user voice messages and
444
+ * videos (their `voice_video_messages` setting and exceptions). Absent everywhere else.
445
+ *
446
+ */
447
+ can_send_voice_video?: boolean;
448
+ /**
449
+ * `restricted` when the account is suspended by its automatic account status; clients show "Restricted
450
+ * account". Absent otherwise.
451
+ *
452
+ */
453
+ account_label?: AccountLabel;
454
+ }
455
+ export interface Birthday {
456
+ day: number;
457
+ month: number;
458
+ /**
459
+ * Optional; `null` when the user keeps the year to themselves.
460
+ */
461
+ year: number | null;
462
+ }
463
+ export interface ProfileMusic {
464
+ /**
465
+ * The clip (at most 30 s). `thumbnail_url` is the cover when the file had one.
466
+ */
467
+ attachment: Attachment;
468
+ title: string | null;
469
+ artist: string | null;
470
+ }
471
+ export interface Attachment {
472
+ id: AttachmentRef;
473
+ kind: AttachmentKind;
474
+ filename: string;
475
+ /**
476
+ * Detected by the server
477
+ */
478
+ content_type: string;
479
+ /**
480
+ * Bytes
481
+ */
482
+ size: number;
483
+ /**
484
+ * Same-origin path (`/api/v2/attachments/{id}/content`) set by the server.
485
+ */
486
+ url: string;
487
+ width?: number | null;
488
+ height?: number | null;
489
+ /**
490
+ * A WebP of at most 480 px (older uploads a JPEG of at most 320 px); for audio the embedded cover.
491
+ */
492
+ thumbnail_url?: string | null;
493
+ /**
494
+ * 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.
495
+ */
496
+ display_url?: string | null;
497
+ /**
498
+ * A ThumbHash (base64) of the image or video poster, to draw a blurred preview before the thumbnail arrives.
499
+ */
500
+ placeholder?: string | null;
501
+ /**
502
+ * Whether the server is still making an optimized copy of a video, GIF or audio file. Clients play `url`
503
+ * meanwhile and swap to the new copy on `attachment_updated`. `null` when there is nothing to do.
504
+ *
505
+ */
506
+ processing?: MediaProcessing | null;
507
+ /**
508
+ * The file as uploaded, when `url` serves an optimized copy; `null` otherwise.
509
+ */
510
+ source_url?: string | null;
511
+ /**
512
+ * A GIF as a muted, looping MP4, much smaller than the GIF; `null` until made or for other files.
513
+ */
514
+ animation_url?: string | null;
515
+ /**
516
+ * Stickers only; a still 128 px WebP for pickers and lists.
517
+ */
518
+ panel_url?: string | null;
519
+ /**
520
+ * Stickers only; a 320 px WebP for messages.
521
+ */
522
+ message_url?: string | null;
523
+ duration_ms?: number | null;
524
+ waveform?: number[] | null;
525
+ tags?: AudioTags;
526
+ drawing?: Drawing;
527
+ }
528
+ /**
529
+ * Audio files (not voice messages) and `profile_music` uploads; what the file says about itself.
530
+ */
531
+ export interface AudioTags {
532
+ title: string | null;
533
+ artist: string | null;
534
+ album?: string | null;
535
+ }
536
+ /**
537
+ * What the sender drew on this image of this message. Clients show the image with the drawing on top
538
+ * and never without it. Absent when the image has no drawing. The same image can carry another drawing
539
+ * in another message.
540
+ *
541
+ */
542
+ export interface Drawing {
543
+ version: number;
544
+ /**
545
+ * @minItems 1
546
+ * @maxItems 200
547
+ */
548
+ items: [DrawingItem, ...DrawingItem[]];
549
+ }
550
+ export interface DrawingItem {
551
+ type: "stroke" | "text";
552
+ color: string;
553
+ /**
554
+ * Stroke only. Line width as a fraction of the image width.
555
+ */
556
+ width?: number;
557
+ /**
558
+ * Stroke only. Flat list of x, y pairs. A drawing has at most 10000 numbers in all its strokes.
559
+ *
560
+ * @minItems 2
561
+ * @maxItems 10000
562
+ */
563
+ points?: [number, number, ...number[]];
564
+ /**
565
+ * Text only. Left edge of the label.
566
+ */
567
+ x?: number;
568
+ /**
569
+ * Text only. Top edge of the label.
570
+ */
571
+ y?: number;
572
+ /**
573
+ * Text only. Font height as a fraction of the image height.
574
+ */
575
+ size?: number;
576
+ /**
577
+ * Text only.
578
+ */
579
+ text?: string;
580
+ }
581
+ export interface ProfileBackground {
582
+ kind: ProfileBackgroundKind;
583
+ /**
584
+ * Set for `media`. An image, an animated GIF or a muted video of at most 15 s; `thumbnail_url` is a still
585
+ * frame to show while it loads and when the viewer prefers reduced motion.
586
+ *
587
+ */
588
+ attachment?: Attachment;
589
+ preset?: BackgroundPreset;
590
+ /**
591
+ * @minItems 1
592
+ * @maxItems 2
593
+ */
594
+ colors?: [BackgroundColor] | [BackgroundColor, BackgroundColor];
595
+ }
596
+ /**
597
+ * 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.
598
+ */
599
+ export interface ServerAttachmentUpdatedEvent {
600
+ type: "attachment_updated";
601
+ event_id: Id;
602
+ chat_id: null;
603
+ data: {
604
+ attachment: Attachment;
605
+ };
606
+ }
607
+ /**
608
+ * Sealed sender keys for this session (see docs/calls-e2ee.md). Sent only to the recipient session.
609
+ */
610
+ export interface ServerCallKeysEvent {
611
+ type: "call_keys";
612
+ event_id: Id;
613
+ chat_id: Id;
614
+ data: CallKeyEnvelopeList;
615
+ }
616
+ export interface CallKeyEnvelopeList {
617
+ call_id: Id;
618
+ epoch: number;
619
+ items: CallKeyEnvelope[];
620
+ }
621
+ /**
622
+ * An HPKE Auth-mode envelope carrying one sender key (see `docs/calls-e2ee.md`).
623
+ */
624
+ export interface CallKeyEnvelope {
625
+ epoch: number;
626
+ sender_user_id: Id;
627
+ sender_session_id: string;
628
+ recipient_session_id: string;
629
+ /**
630
+ * HPKE encapsulated key, base64url without padding.
631
+ */
632
+ enc: string;
633
+ /**
634
+ * Sealed sender key, base64url without padding.
635
+ */
636
+ ciphertext: string;
637
+ }
638
+ /**
639
+ * 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.
640
+ */
641
+ export interface ServerCallUpdatedEvent {
642
+ type: "call_updated";
643
+ event_id: Id;
644
+ chat_id: Id;
645
+ data: {
646
+ call: Call;
647
+ };
648
+ }
649
+ export interface Call {
650
+ id: Id;
651
+ chat_id: Id;
652
+ kind: "direct" | "group";
653
+ state: CallState;
654
+ end_reason: CallEndReason | null;
655
+ initiator_id: Id;
656
+ created_at: Timestamp;
657
+ /**
658
+ * First answer; `null` while nobody answered.
659
+ */
660
+ started_at: Timestamp | null;
661
+ ended_at: Timestamp | null;
662
+ /**
663
+ * When ringing invitations of this call turn into `missed`.
664
+ */
665
+ ring_expires_at: string;
666
+ /**
667
+ * Key epoch; increases whenever the set of joined sessions or their identity keys change.
668
+ */
669
+ epoch: number;
670
+ /**
671
+ * Increases with every change of the call; ignore events with a lower version than one already seen.
672
+ */
673
+ version: number;
674
+ max_participants: number;
675
+ /**
676
+ * Everyone invited or joined, the initiator first.
677
+ */
678
+ participants: CallParticipant[];
679
+ }
680
+ export interface CallParticipant {
681
+ user_id: Id;
682
+ state: CallParticipantState;
683
+ /**
684
+ * The session that joined; `null` unless `state` is `joined`.
685
+ */
686
+ session_id: string | null;
687
+ /**
688
+ * Call identity of the joined session; `null` unless `state` is `joined`.
689
+ */
690
+ identity_key: CallIdentityKey | null;
691
+ /**
692
+ * When the participant last joined; `null` if never.
693
+ */
694
+ joined_at: Timestamp | null;
263
695
  }
264
696
  /**
265
697
  * A chat was created with you.
@@ -281,11 +713,36 @@ export interface Chat {
281
713
  name: string;
282
714
  avatar_url: string | null;
283
715
  /**
284
- * The other user of a direct chat; `null` for groups.
716
+ * The other user of a direct chat (the caller in their "Saved Messages" chat); `null` for groups.
285
717
  */
286
718
  peer: User | null;
287
719
  is_pinned: boolean;
720
+ /**
721
+ * Order of a pinned chat among the caller's pinned chats, lowest first; `null` when not pinned.
722
+ */
723
+ pin_position: number | null;
724
+ /**
725
+ * Whether the caller archived the chat (only for the caller).
726
+ */
727
+ is_archived: boolean;
728
+ /**
729
+ * Whether the chat is in the caller's Requests folder: a stranger opened it, and the caller has not
730
+ * replied, accepted, pinned or archived it yet (only for the caller).
731
+ *
732
+ */
733
+ is_request: boolean;
288
734
  unread_count: number;
735
+ /**
736
+ * The oldest message the caller has not read (the same messages `unread_count` counts: not their own,
737
+ * not system messages, not deleted); `null` when nothing is unread. Clients open the chat around it and
738
+ * show the "new messages" divider above it.
739
+ *
740
+ */
741
+ first_unread_message_id: Id | null;
742
+ /**
743
+ * The caller's read marker (`POST /chats/{chat_id}/read`); `null` before their first read.
744
+ */
745
+ last_read_message_id: Id | null;
289
746
  last_message: Message | null;
290
747
  /**
291
748
  * Only for groups.
@@ -302,47 +759,115 @@ export interface Message {
302
759
  */
303
760
  sender: User | null;
304
761
  /**
305
- * Text, or the caption of a file; `null` when deleted.
762
+ * Text, the caption of a file, or the emoji of a sticker; `null` when deleted.
306
763
  */
307
764
  content: string | null;
308
765
  attachment: Attachment | null;
309
766
  reply_to: Id | null;
767
+ reply_preview?: ReplyPreview;
310
768
  forwarded_from: ForwardedFrom | null;
769
+ sticker?: Sticker;
770
+ /**
771
+ * Ordered images and videos of an album. The first item is also returned as attachment for older clients.
772
+ *
773
+ * @minItems 2
774
+ * @maxItems 10
775
+ */
776
+ attachments?:
777
+ | [Attachment, Attachment]
778
+ | [Attachment, Attachment, Attachment]
779
+ | [Attachment, Attachment, Attachment, Attachment]
780
+ | [Attachment, Attachment, Attachment, Attachment, Attachment]
781
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
782
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
783
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
784
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
785
+ | [
786
+ Attachment,
787
+ Attachment,
788
+ Attachment,
789
+ Attachment,
790
+ Attachment,
791
+ Attachment,
792
+ Attachment,
793
+ Attachment,
794
+ Attachment,
795
+ Attachment
796
+ ];
311
797
  reactions: Reaction[];
312
798
  read_by: ReadReceipt[];
313
799
  created_at: Timestamp;
314
800
  edited_at: Timestamp | null;
315
801
  is_deleted: boolean;
316
- client_temp_id?: ClientTempId;
317
- }
318
- export interface Attachment {
319
- id: AttachmentRef;
320
- kind: AttachmentKind;
321
- filename: string;
322
802
  /**
323
- * Detected by the server
803
+ * `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
804
+ * moderation" instead of the deleted placeholder. Absent otherwise.
805
+ *
324
806
  */
325
- content_type: string;
807
+ removed_by_moderation?: boolean;
326
808
  /**
327
- * Bytes
809
+ * Why moderation removed the message; only for its sender, absent for everyone else.
328
810
  */
329
- size: number;
811
+ moderation_reason?: ModerationRemovalReason;
812
+ system_event?: SystemEvent;
813
+ client_temp_id?: ClientTempId;
814
+ }
815
+ /**
816
+ * What a reply shows of the message it answers, so a client can draw the quote without loading that
817
+ * message. Set on messages of history pages and `message` events when the recipient can see the answered
818
+ * message; absent when it is gone or hidden for them, and on chat-list previews and search results.
819
+ *
820
+ */
821
+ export interface ReplyPreview {
822
+ id: Id;
823
+ type: MessageType;
824
+ sender: User | null;
330
825
  /**
331
- * Same-origin path (`/api/v2/attachments/{id}/content`) set by the server.
826
+ * The first 100 characters of the text or caption; `null` when deleted or empty.
332
827
  */
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;
828
+ content: string | null;
829
+ attachment: Attachment | null;
830
+ is_deleted: boolean;
831
+ /**
832
+ * `true` when moderation removed the answered message. Absent otherwise.
833
+ */
834
+ removed_by_moderation?: boolean;
339
835
  }
340
836
  export interface ForwardedFrom {
341
837
  message_id: Id;
838
+ /**
839
+ * The original sender; `null` when their account is gone or their `forward_link` setting hides it from the
840
+ * requesting user. Clients then show `sender_name` as plain text, not as a link to a profile.
841
+ *
842
+ */
342
843
  sender_id: Id | null;
343
844
  sender_name: string;
344
845
  }
846
+ /**
847
+ * The sticker of a `sticker` message; absent for other types and when deleted. `attachment` carries the
848
+ * same image, so older clients show a sticker as a picture.
849
+ *
850
+ */
851
+ export interface Sticker {
852
+ id: Id;
853
+ pack_id: Id;
854
+ /**
855
+ * The share link of the sticker's pack when a user made it; missing for built-in packs. A client that
856
+ * shows the pack of a sticker someone sent opens it with `GET /stickers/links/{slug}`.
857
+ *
858
+ */
859
+ pack_slug?: StickerPackSlug;
860
+ /**
861
+ * The emoji the sticker stands for, for previews, notifications and search.
862
+ */
863
+ emoji: string;
864
+ is_animated: boolean;
865
+ image: Attachment;
866
+ }
345
867
  export interface Reaction {
868
+ /**
869
+ * A Unicode emoji, or `c:<id>` for a custom emoji (`GET /emoji/items/{id}/image`).
870
+ */
346
871
  emoji: string;
347
872
  user_id: Id;
348
873
  }
@@ -350,6 +875,45 @@ export interface ReadReceipt {
350
875
  user_id: Id;
351
876
  read_at: Timestamp;
352
877
  }
878
+ /**
879
+ * Why moderation removed something, shown only to its author.
880
+ */
881
+ export interface ModerationRemovalReason {
882
+ code: ModerationReason;
883
+ /**
884
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
885
+ * never by a person's name.
886
+ *
887
+ */
888
+ text: string;
889
+ }
890
+ /**
891
+ * What a `system` message records; set on system messages only, whose `content` is then `null`. The names
892
+ * are the display names at the time of the event. `target` fields are set for `member_added` and
893
+ * `member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
894
+ * initiator.
895
+ *
896
+ */
897
+ export interface SystemEvent {
898
+ kind: SystemEventKind;
899
+ actor_id: Id | null;
900
+ actor_name: string;
901
+ target_id?: Id;
902
+ target_name?: string;
903
+ call?: CallSummary;
904
+ }
905
+ /**
906
+ * The call a `call` system message records.
907
+ */
908
+ export interface CallSummary {
909
+ call_id: Id;
910
+ kind: "direct" | "group";
911
+ outcome: CallEndReason;
912
+ /**
913
+ * From the first answer to the end; `null` if nobody answered.
914
+ */
915
+ duration_seconds: number | null;
916
+ }
353
917
  /**
354
918
  * A chat was deleted, or you were removed from it.
355
919
  */
@@ -360,7 +924,7 @@ export interface ServerChatDeletedEvent {
360
924
  data: {};
361
925
  }
362
926
  /**
363
- * The chat-list entry changed (last message, unread count, pin).
927
+ * The chat-list entry changed (last message, unread count, pin, archive, leaving the Requests folder).
364
928
  */
365
929
  export interface ServerChatListUpdateEvent {
366
930
  type: "chat_list_update";
@@ -371,7 +935,7 @@ export interface ServerChatListUpdateEvent {
371
935
  };
372
936
  }
373
937
  /**
374
- * A message was deleted for everyone (deleting for yourself is only sent to your other devices).
938
+ * A message was deleted for everyone (deleting for yourself is only sent to your other devices), or removed by moderation.
375
939
  */
376
940
  export interface ServerDeleteEvent {
377
941
  type: "delete";
@@ -380,8 +944,25 @@ export interface ServerDeleteEvent {
380
944
  data: {
381
945
  message_id: Id;
382
946
  scope: "me" | "everyone";
947
+ /**
948
+ * `true` when moderation removed the message (`scope` is then `everyone`). Absent otherwise.
949
+ */
950
+ removed_by_moderation?: boolean;
951
+ moderation_reason?: ModerationRemovalReason1;
383
952
  };
384
953
  }
954
+ /**
955
+ * Why moderation removed something, shown only to its author.
956
+ */
957
+ export interface ModerationRemovalReason1 {
958
+ code: ModerationReason;
959
+ /**
960
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
961
+ * never by a person's name.
962
+ *
963
+ */
964
+ text: string;
965
+ }
385
966
  /**
386
967
  * A message was edited.
387
968
  */
@@ -403,6 +984,25 @@ export interface ServerErrorEvent {
403
984
  data: {
404
985
  code: ErrorCode;
405
986
  message?: string;
987
+ /**
988
+ * An action the account status blocks. Unknown values must be shown as a generic restriction.
989
+ */
990
+ restriction?:
991
+ | "start_direct"
992
+ | "invite_to_group"
993
+ | "call"
994
+ | "create_group"
995
+ | "upload"
996
+ | "forward"
997
+ | "edit_profile"
998
+ | "publish_pack"
999
+ | "search"
1000
+ | "send"
1001
+ | "manage_group";
1002
+ /**
1003
+ * The setting or field that caused the error, for example `voice_video_messages` for a voice message or video the recipient does not accept.
1004
+ */
1005
+ field?: string;
406
1006
  };
407
1007
  client_temp_id?: ClientTempId;
408
1008
  }
@@ -422,6 +1022,10 @@ export interface Group {
422
1022
  name: string;
423
1023
  description: string | null;
424
1024
  avatar_url: string | null;
1025
+ /**
1026
+ * The banner and page background of the group profile; set by the owner and admins.
1027
+ */
1028
+ background: ProfileBackground | null;
425
1029
  owner_id: Id;
426
1030
  my_role: GroupRole;
427
1031
  members: GroupMember[];
@@ -456,6 +1060,19 @@ export interface ServerHelloEvent {
456
1060
  user_id: Id;
457
1061
  };
458
1062
  }
1063
+ /**
1064
+ * 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.
1065
+ */
1066
+ export interface ServerHistoryClearedEvent {
1067
+ type: "history_cleared";
1068
+ event_id: Id;
1069
+ chat_id: Id;
1070
+ data: {
1071
+ before_message_id: Id;
1072
+ scope: "me" | "everyone";
1073
+ actor_id: Id;
1074
+ };
1075
+ }
459
1076
  /**
460
1077
  * A new message in a chat.
461
1078
  */
@@ -517,6 +1134,92 @@ export interface ServerReadEvent {
517
1134
  read_at: Timestamp;
518
1135
  };
519
1136
  }
1137
+ export interface ServerRecoveryRequestEvent {
1138
+ type: "recovery_request";
1139
+ event_id: string;
1140
+ chat_id: null;
1141
+ data: {
1142
+ /**
1143
+ * Approval handle for POST /auth/recovery-requests/{requestId}/approve and /deny. It is not the requester's capability.
1144
+ */
1145
+ request_id: string;
1146
+ user_agent: string;
1147
+ location: Location | null;
1148
+ /**
1149
+ * @minItems 3
1150
+ * @maxItems 3
1151
+ */
1152
+ choices: [number, number, number];
1153
+ expires_at: string;
1154
+ };
1155
+ }
1156
+ /**
1157
+ * Approximate location of a client address, looked up in an offline GeoIP database (IP geolocation by
1158
+ * DB-IP, https://db-ip.com, CC BY 4.0). The address itself is never exposed. Each field is `null` when the
1159
+ * database does not know it; clients localise the country name from `country_code`.
1160
+ *
1161
+ */
1162
+ export interface Location {
1163
+ /**
1164
+ * City name in English
1165
+ */
1166
+ city: string | null;
1167
+ /**
1168
+ * ISO 3166-1 alpha-2 country code
1169
+ */
1170
+ country_code: string | null;
1171
+ /**
1172
+ * Country name in English
1173
+ */
1174
+ country: string | null;
1175
+ }
1176
+ /**
1177
+ * The moderation team reviewed something the current user reported (sent only to the reporter's own sessions).
1178
+ */
1179
+ export interface ServerReportOutcomeEvent {
1180
+ type: "report_outcome";
1181
+ event_id: Id;
1182
+ chat_id: null;
1183
+ data: ReportOutcome;
1184
+ }
1185
+ export interface ReportOutcome {
1186
+ id: Id;
1187
+ subject_type: ReportSubjectType;
1188
+ /**
1189
+ * The reported user, sticker pack or emoji pack.
1190
+ */
1191
+ subject_id: Id;
1192
+ outcome: ReportOutcomeKind;
1193
+ created_at: Timestamp;
1194
+ read: boolean;
1195
+ }
1196
+ export interface ServerSecurityAlertEvent {
1197
+ type: "security_alert";
1198
+ event_id: Id;
1199
+ chat_id: null;
1200
+ data: {
1201
+ type:
1202
+ | "password_changed"
1203
+ | "recovery_key_changed"
1204
+ | "2fa_enabled"
1205
+ | "2fa_disabled"
1206
+ | "passkey_added"
1207
+ | "passkey_removed"
1208
+ | "recovery_email_changed"
1209
+ | "recovery_email_removed"
1210
+ | "passkey_counter_warning"
1211
+ | "login"
1212
+ | "login_2fa"
1213
+ | "passkey_login"
1214
+ | "qr_login_approved";
1215
+ user_agent?: string;
1216
+ created_at?: string;
1217
+ /**
1218
+ * The session that made the change, when a signed-in session made it. Clients skip alerts for their own session.
1219
+ */
1220
+ session_id?: string;
1221
+ };
1222
+ }
520
1223
  export interface ServerSecurityNoticeEvent {
521
1224
  type: "security_notice";
522
1225
  event_id: Id;
@@ -526,7 +1229,7 @@ export interface ServerSecurityNoticeEvent {
526
1229
  };
527
1230
  }
528
1231
  /**
529
- * A user started or stopped typing.
1232
+ * 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
1233
  */
531
1234
  export interface ServerTypingEvent {
532
1235
  type: "typing";
@@ -535,5 +1238,22 @@ export interface ServerTypingEvent {
535
1238
  data: {
536
1239
  user_id: Id;
537
1240
  is_typing: boolean;
1241
+ /**
1242
+ * What the user is doing. New values may be added: show an unknown one like `typing`.
1243
+ */
1244
+ action:
1245
+ "typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
1246
+ };
1247
+ }
1248
+ /**
1249
+ * 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.
1250
+ */
1251
+ export interface ServerUserUpdatedEvent {
1252
+ type: "user_updated";
1253
+ event_id: Id;
1254
+ chat_id: null;
1255
+ data: {
1256
+ user_id: Id;
1257
+ profile_version: number;
538
1258
  };
539
1259
  }