@myronsi/messenger-api 2.1.0-alpha.45.next.154 → 2.1.0-alpha.47
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.
- package/CHANGELOG.md +34 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +887 -21
- package/dist/schema.d.ts +1147 -22
- package/dist/ws-docs.json +58 -1
- package/dist/ws-events.d.ts +240 -9
- package/dist/ws-events.schema.json +1677 -564
- package/package.json +1 -1
package/dist/ws-docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`, and `data.field` when one setting or field caused it (for example `voice_video_messages`). `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted; `delete` with `removed_by_moderation` when moderation removed it (the sender's copy also carries `moderation_reason`) |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `pin_update` | A message was pinned or unpinned for everyone (to all members) or only for you (`scope: me`, to your own sessions); carries `pinned_message_count` for you |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\r\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\r\n| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\n| `attachment_updated` | An optimized copy of an attachment you can see is ready (or failed): replace it in your messages |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
2
|
+
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`, and `data.field` when one setting or field caused it (for example `voice_video_messages`). `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted; `delete` with `removed_by_moderation` when moderation removed it (the sender's copy also carries `moderation_reason`) |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `pin_update` | A message was pinned or unpinned for everyone (to all members) or only for you (`scope: me`, to your own sessions); carries `pinned_message_count` for you |\r\n| `poll_updated` | A vote changed or a poll closed; carries the whole `Poll` as you see it (results only once you voted, for the creator, or after closing). Keep the highest `version` |\r\n| `import_update` | An imported history of the chat started, finished or is being removed (to all members); reload the chat on `done` and `removing` |\n| `import_sender_update` | A name of an imported history was suggested for a member, declined, confirmed or withdrawn; suggestions and declines go only to the importer and that member |\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\r\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\r\n| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\n| `attachment_updated` | An optimized copy of an attachment you can see is ready (or failed): replace it in your messages |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
3
3
|
"examples": {
|
|
4
4
|
"client/delete.json": {
|
|
5
5
|
"type": "delete",
|
|
@@ -520,6 +520,30 @@
|
|
|
520
520
|
"actor_id": "7"
|
|
521
521
|
}
|
|
522
522
|
},
|
|
523
|
+
"server/import_sender_update.json": {
|
|
524
|
+
"type": "import_sender_update",
|
|
525
|
+
"event_id": "7217400317439950014",
|
|
526
|
+
"chat_id": "42",
|
|
527
|
+
"data": {
|
|
528
|
+
"import_id": "3",
|
|
529
|
+
"sender": {
|
|
530
|
+
"key": "s2",
|
|
531
|
+
"name": "Bert K.",
|
|
532
|
+
"message_count": 1502,
|
|
533
|
+
"state": "pending",
|
|
534
|
+
"user_id": "7"
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
"server/import_update.json": {
|
|
539
|
+
"type": "import_update",
|
|
540
|
+
"event_id": "7217400317439950013",
|
|
541
|
+
"chat_id": "42",
|
|
542
|
+
"data": {
|
|
543
|
+
"import_id": "3",
|
|
544
|
+
"state": "done"
|
|
545
|
+
}
|
|
546
|
+
},
|
|
523
547
|
"server/message.json": {
|
|
524
548
|
"type": "message",
|
|
525
549
|
"event_id": "7217400317439950009",
|
|
@@ -569,6 +593,39 @@
|
|
|
569
593
|
"at": "2026-11-21T10:15:00Z"
|
|
570
594
|
}
|
|
571
595
|
},
|
|
596
|
+
"server/poll_updated.json": {
|
|
597
|
+
"type": "poll_updated",
|
|
598
|
+
"event_id": "7217400317439950013",
|
|
599
|
+
"chat_id": "42",
|
|
600
|
+
"data": {
|
|
601
|
+
"message_id": "7217400317439950002",
|
|
602
|
+
"poll": {
|
|
603
|
+
"question": "Where do we meet?",
|
|
604
|
+
"options": [
|
|
605
|
+
{
|
|
606
|
+
"text": "Café",
|
|
607
|
+
"voter_count": 3
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"text": "Park",
|
|
611
|
+
"voter_count": 1
|
|
612
|
+
}
|
|
613
|
+
],
|
|
614
|
+
"multiple_answers": false,
|
|
615
|
+
"anonymous": true,
|
|
616
|
+
"quiz": false,
|
|
617
|
+
"explanation": null,
|
|
618
|
+
"close_at": null,
|
|
619
|
+
"closed_at": null,
|
|
620
|
+
"total_voters": 4,
|
|
621
|
+
"my_votes": [
|
|
622
|
+
0
|
|
623
|
+
],
|
|
624
|
+
"can_close": false,
|
|
625
|
+
"version": 4
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
},
|
|
572
629
|
"server/presence.json": {
|
|
573
630
|
"type": "presence",
|
|
574
631
|
"event_id": "7217400317439950009",
|
package/dist/ws-events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.47. Do not edit. */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Any WebSocket event, in either direction.
|
|
@@ -48,8 +48,11 @@ export type ServerEvent =
|
|
|
48
48
|
| ServerGroupUpdatedEvent
|
|
49
49
|
| ServerHelloEvent
|
|
50
50
|
| ServerHistoryClearedEvent
|
|
51
|
+
| ServerImportSenderUpdateEvent
|
|
52
|
+
| ServerImportUpdateEvent
|
|
51
53
|
| ServerMessageEvent
|
|
52
54
|
| ServerPinUpdateEvent
|
|
55
|
+
| ServerPollUpdatedEvent
|
|
53
56
|
| ServerPresenceEvent
|
|
54
57
|
| ServerReactionAddEvent
|
|
55
58
|
| ServerReactionRemoveEvent
|
|
@@ -135,8 +138,15 @@ export type CallParticipantState = "ringing" | "joined" | "declined" | "missed"
|
|
|
135
138
|
*/
|
|
136
139
|
export type CallIdentityKey = string;
|
|
137
140
|
export type ChatType = "direct" | "group";
|
|
138
|
-
|
|
141
|
+
/**
|
|
142
|
+
* `poll`, `contact` and `location` carry their data in `Message.poll`, `Message.contact` and
|
|
143
|
+
* `Message.location`. For older clients their `content` holds a short plain-text summary: `📊 <question>`,
|
|
144
|
+
* `👤 @<username>`, or `📍 <place name> <OpenStreetMap link>`.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
export type MessageType = "text" | "file" | "voice" | "system" | "sticker" | "poll" | "contact" | "location";
|
|
139
148
|
export type StickerPackSlug = string;
|
|
149
|
+
export type ImportSource = "telegram" | "whatsapp";
|
|
140
150
|
export type SystemEventKind =
|
|
141
151
|
| "group_created"
|
|
142
152
|
| "member_added"
|
|
@@ -145,7 +155,13 @@ export type SystemEventKind =
|
|
|
145
155
|
| "member_left"
|
|
146
156
|
| "call"
|
|
147
157
|
| "message_pinned"
|
|
148
|
-
| "message_unpinned"
|
|
158
|
+
| "message_unpinned"
|
|
159
|
+
| "history_imported"
|
|
160
|
+
| "history_import_ended"
|
|
161
|
+
| "imported_note"
|
|
162
|
+
| "group_renamed"
|
|
163
|
+
| "group_avatar_changed"
|
|
164
|
+
| "owner_transferred";
|
|
149
165
|
/**
|
|
150
166
|
* A moderator may delete other members' messages; owners and admins also manage the group.
|
|
151
167
|
*/
|
|
@@ -186,6 +202,8 @@ export type ErrorCode =
|
|
|
186
202
|
| "stale_epoch"
|
|
187
203
|
| "limit_reached"
|
|
188
204
|
| "account_restricted"
|
|
205
|
+
| "poll_closed"
|
|
206
|
+
| "quiz_answered"
|
|
189
207
|
| "internal_error";
|
|
190
208
|
/**
|
|
191
209
|
* A username or a group's public name. One name space for both, unique ignoring case; links are `/@name` on the
|
|
@@ -193,6 +211,21 @@ export type ErrorCode =
|
|
|
193
211
|
*
|
|
194
212
|
*/
|
|
195
213
|
export type PublicName = string;
|
|
214
|
+
/**
|
|
215
|
+
* The client's key for one name of the export.
|
|
216
|
+
*/
|
|
217
|
+
export type ImportSenderKey = string;
|
|
218
|
+
/**
|
|
219
|
+
* `me`: the importer's own messages. `unassigned`: shown as text. `pending`: suggested for `user_id`, who has
|
|
220
|
+
* not answered. `confirmed`: `user_id` confirmed; the messages show their account. `declined`: the suggested
|
|
221
|
+
* member said no; shown as text.
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
export type ImportSenderState = "me" | "unassigned" | "pending" | "confirmed" | "declined";
|
|
225
|
+
/**
|
|
226
|
+
* `running`: messages are being added. `done`: finished. `removing`: being removed.
|
|
227
|
+
*/
|
|
228
|
+
export type ChatImportState = "running" | "done" | "removing";
|
|
196
229
|
/**
|
|
197
230
|
* `me`: only for the caller. `everyone`: for every member of the chat.
|
|
198
231
|
*/
|
|
@@ -790,7 +823,9 @@ export interface Message {
|
|
|
790
823
|
*/
|
|
791
824
|
sender: User | null;
|
|
792
825
|
/**
|
|
793
|
-
* Text, the caption of a file,
|
|
826
|
+
* Text, the caption of a file, the emoji of a sticker, or the plain-text summary of a poll, contact or
|
|
827
|
+
* location (see `MessageType`); `null` when deleted.
|
|
828
|
+
*
|
|
794
829
|
*/
|
|
795
830
|
content: string | null;
|
|
796
831
|
attachment: Attachment | null;
|
|
@@ -827,9 +862,13 @@ export interface Message {
|
|
|
827
862
|
];
|
|
828
863
|
reactions: Reaction[];
|
|
829
864
|
read_by: ReadReceipt[];
|
|
865
|
+
/**
|
|
866
|
+
* When the message was sent; for an imported message, when it was sent in the other messenger.
|
|
867
|
+
*/
|
|
830
868
|
created_at: Timestamp;
|
|
831
869
|
edited_at: Timestamp | null;
|
|
832
870
|
is_deleted: boolean;
|
|
871
|
+
import?: MessageImport;
|
|
833
872
|
/**
|
|
834
873
|
* `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
|
|
835
874
|
* moderation" instead of the deleted placeholder. Absent otherwise.
|
|
@@ -876,6 +915,9 @@ export interface Message {
|
|
|
876
915
|
* `true` when an owner or admin wrote `@all`; it mentions every member. Absent otherwise.
|
|
877
916
|
*/
|
|
878
917
|
mentions_all?: boolean;
|
|
918
|
+
poll?: Poll;
|
|
919
|
+
contact?: ContactCard;
|
|
920
|
+
location?: MessageLocation;
|
|
879
921
|
}
|
|
880
922
|
/**
|
|
881
923
|
* What a reply shows of the message it answers, so a client can draw the quote without loading that
|
|
@@ -940,6 +982,25 @@ export interface ReadReceipt {
|
|
|
940
982
|
user_id: Id;
|
|
941
983
|
read_at: Timestamp;
|
|
942
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Set on messages that came from an import.
|
|
987
|
+
*/
|
|
988
|
+
export interface MessageImport {
|
|
989
|
+
import_id: Id;
|
|
990
|
+
source: ImportSource;
|
|
991
|
+
original_at: Timestamp;
|
|
992
|
+
/**
|
|
993
|
+
* The name in the export; absent on system messages.
|
|
994
|
+
*/
|
|
995
|
+
sender_name?: string;
|
|
996
|
+
/**
|
|
997
|
+
* `me`: the importer's own message, `sender` is the importer. `confirmed`: the member confirmed the name,
|
|
998
|
+
* `sender` is that member. `unconfirmed`: `sender` is `null`; show `sender_name` as text. Absent on system
|
|
999
|
+
* messages.
|
|
1000
|
+
*
|
|
1001
|
+
*/
|
|
1002
|
+
sender_state?: "me" | "confirmed" | "unconfirmed";
|
|
1003
|
+
}
|
|
943
1004
|
/**
|
|
944
1005
|
* Why moderation removed something, shown only to its author.
|
|
945
1006
|
*/
|
|
@@ -954,9 +1015,13 @@ export interface ModerationRemovalReason {
|
|
|
954
1015
|
}
|
|
955
1016
|
/**
|
|
956
1017
|
* What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
957
|
-
* are the display names at the time of the event. `target` fields are set for `member_added
|
|
958
|
-
* `member_removed
|
|
959
|
-
*
|
|
1018
|
+
* are the display names at the time of the event. `target` fields are set for `member_added`,
|
|
1019
|
+
* `member_removed` and `owner_transferred` (the new owner; `actor` is the previous one). `call` is set for
|
|
1020
|
+
* `call` messages: one per call, posted when the call ends, `actor` is the initiator. `message_id` and
|
|
1021
|
+
* `snippet` are set for `message_pinned` and `message_unpinned`. `old_name` and `new_name` are set for
|
|
1022
|
+
* `group_renamed`, `avatar_removed` for `group_avatar_changed`.
|
|
1023
|
+
* `history_imported` opens and `history_import_ended` closes an imported history; both carry `import`, and
|
|
1024
|
+
* `actor` is the importer. `imported_note` is a line of the export that is not a message; its text is `text`.
|
|
960
1025
|
*
|
|
961
1026
|
*/
|
|
962
1027
|
export interface SystemEvent {
|
|
@@ -971,12 +1036,24 @@ export interface SystemEvent {
|
|
|
971
1036
|
*/
|
|
972
1037
|
message_id?: Id;
|
|
973
1038
|
/**
|
|
974
|
-
* Start of the pinned message's text at the time of the event (at most 60 characters plus `…`)
|
|
975
|
-
* message without text
|
|
1039
|
+
* Start of the pinned message's text at the time of the event (at most 60 characters plus `…`): the question
|
|
1040
|
+
* of a poll, the place name of a location. Empty for a message without text and for a contact, which clients
|
|
1041
|
+
* name by its `message_type`.
|
|
976
1042
|
*
|
|
977
1043
|
*/
|
|
978
1044
|
snippet?: string;
|
|
979
1045
|
message_type?: MessageType;
|
|
1046
|
+
old_name?: string;
|
|
1047
|
+
new_name?: string;
|
|
1048
|
+
/**
|
|
1049
|
+
* `true` when the group photo was removed, `false` when a new one was set.
|
|
1050
|
+
*/
|
|
1051
|
+
avatar_removed?: boolean;
|
|
1052
|
+
import?: ImportSummary;
|
|
1053
|
+
/**
|
|
1054
|
+
* The line of the export, for `imported_note`.
|
|
1055
|
+
*/
|
|
1056
|
+
text?: string;
|
|
980
1057
|
}
|
|
981
1058
|
/**
|
|
982
1059
|
* The call a `call` system message records.
|
|
@@ -990,6 +1067,83 @@ export interface CallSummary {
|
|
|
990
1067
|
*/
|
|
991
1068
|
duration_seconds: number | null;
|
|
992
1069
|
}
|
|
1070
|
+
export interface ImportSummary {
|
|
1071
|
+
import_id: Id;
|
|
1072
|
+
source: ImportSource;
|
|
1073
|
+
message_count: number;
|
|
1074
|
+
first_at: Timestamp;
|
|
1075
|
+
last_at: Timestamp;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* The poll of a `poll` message as the requesting user sees it; absent for other types, when deleted and in chat-list previews.
|
|
1079
|
+
*/
|
|
1080
|
+
export interface Poll {
|
|
1081
|
+
question: string;
|
|
1082
|
+
options: PollOption[];
|
|
1083
|
+
multiple_answers: boolean;
|
|
1084
|
+
anonymous: boolean;
|
|
1085
|
+
quiz: boolean;
|
|
1086
|
+
/**
|
|
1087
|
+
* The explanation of a quiz once the user sees the results.
|
|
1088
|
+
*/
|
|
1089
|
+
explanation: string | null;
|
|
1090
|
+
close_at: Timestamp | null;
|
|
1091
|
+
closed_at: Timestamp | null;
|
|
1092
|
+
/**
|
|
1093
|
+
* People who voted, each counted once even with several answers.
|
|
1094
|
+
*/
|
|
1095
|
+
total_voters: number | null;
|
|
1096
|
+
/**
|
|
1097
|
+
* Indexes of the options the user voted for; empty when they have not voted.
|
|
1098
|
+
*/
|
|
1099
|
+
my_votes: number[];
|
|
1100
|
+
/**
|
|
1101
|
+
* The user may close the poll now.
|
|
1102
|
+
*/
|
|
1103
|
+
can_close: boolean;
|
|
1104
|
+
/**
|
|
1105
|
+
* Grows with every vote and when the poll closes; keep the poll with the highest version.
|
|
1106
|
+
*/
|
|
1107
|
+
version: number;
|
|
1108
|
+
}
|
|
1109
|
+
export interface PollOption {
|
|
1110
|
+
text: string;
|
|
1111
|
+
voter_count: number | null;
|
|
1112
|
+
/**
|
|
1113
|
+
* Set on every option of a quiz once the user sees the results; absent otherwise.
|
|
1114
|
+
*/
|
|
1115
|
+
is_correct?: boolean;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* The shared user of a `contact` message; absent for other types, when deleted and in chat-list previews.
|
|
1119
|
+
*/
|
|
1120
|
+
export interface ContactCard {
|
|
1121
|
+
user_id: Id;
|
|
1122
|
+
/**
|
|
1123
|
+
* The shared user as the requesting user may see them now, not as they were when the card was sent; `null`
|
|
1124
|
+
* when the account is gone.
|
|
1125
|
+
*
|
|
1126
|
+
*/
|
|
1127
|
+
user: User | null;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* The place of a `location` message; absent for other types and when deleted.
|
|
1131
|
+
*/
|
|
1132
|
+
export interface MessageLocation {
|
|
1133
|
+
latitude: number;
|
|
1134
|
+
longitude: number;
|
|
1135
|
+
accuracy_m: number | null;
|
|
1136
|
+
title: string | null;
|
|
1137
|
+
map: MapImage;
|
|
1138
|
+
}
|
|
1139
|
+
export interface MapImage {
|
|
1140
|
+
/**
|
|
1141
|
+
* `GET /maps/static` with the signed point; load it like other API images
|
|
1142
|
+
*/
|
|
1143
|
+
url: string;
|
|
1144
|
+
width: number;
|
|
1145
|
+
height: number;
|
|
1146
|
+
}
|
|
993
1147
|
/**
|
|
994
1148
|
* A chat was deleted, or you were removed from it.
|
|
995
1149
|
*/
|
|
@@ -1155,6 +1309,36 @@ export interface ServerHistoryClearedEvent {
|
|
|
1155
1309
|
actor_id: Id;
|
|
1156
1310
|
};
|
|
1157
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* 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).
|
|
1314
|
+
*/
|
|
1315
|
+
export interface ServerImportSenderUpdateEvent {
|
|
1316
|
+
type: "import_sender_update";
|
|
1317
|
+
event_id: Id;
|
|
1318
|
+
chat_id: Id;
|
|
1319
|
+
data: {
|
|
1320
|
+
import_id: Id;
|
|
1321
|
+
sender: {
|
|
1322
|
+
key: ImportSenderKey;
|
|
1323
|
+
name: string;
|
|
1324
|
+
message_count: number;
|
|
1325
|
+
state: ImportSenderState;
|
|
1326
|
+
user_id?: Id;
|
|
1327
|
+
};
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* 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.
|
|
1332
|
+
*/
|
|
1333
|
+
export interface ServerImportUpdateEvent {
|
|
1334
|
+
type: "import_update";
|
|
1335
|
+
event_id: Id;
|
|
1336
|
+
chat_id: Id;
|
|
1337
|
+
data: {
|
|
1338
|
+
import_id: Id;
|
|
1339
|
+
state: ChatImportState;
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1158
1342
|
/**
|
|
1159
1343
|
* A new message in a chat.
|
|
1160
1344
|
*/
|
|
@@ -1185,6 +1369,53 @@ export interface ServerPinUpdateEvent {
|
|
|
1185
1369
|
pinned_message_count?: number;
|
|
1186
1370
|
};
|
|
1187
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* 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.
|
|
1374
|
+
*/
|
|
1375
|
+
export interface ServerPollUpdatedEvent {
|
|
1376
|
+
type: "poll_updated";
|
|
1377
|
+
event_id: Id;
|
|
1378
|
+
chat_id: Id;
|
|
1379
|
+
data: {
|
|
1380
|
+
message_id: Id;
|
|
1381
|
+
poll: Poll1;
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* A poll as the requesting user sees it. Results (`voter_count`, `total_voters`, `is_correct`, `explanation`)
|
|
1386
|
+
* are `null` or absent until that user voted, unless they created the poll or it is closed. A poll is closed
|
|
1387
|
+
* when `closed_at` is set; clients also treat it as closed once `close_at` has passed.
|
|
1388
|
+
*
|
|
1389
|
+
*/
|
|
1390
|
+
export interface Poll1 {
|
|
1391
|
+
question: string;
|
|
1392
|
+
options: PollOption[];
|
|
1393
|
+
multiple_answers: boolean;
|
|
1394
|
+
anonymous: boolean;
|
|
1395
|
+
quiz: boolean;
|
|
1396
|
+
/**
|
|
1397
|
+
* The explanation of a quiz once the user sees the results.
|
|
1398
|
+
*/
|
|
1399
|
+
explanation: string | null;
|
|
1400
|
+
close_at: Timestamp | null;
|
|
1401
|
+
closed_at: Timestamp | null;
|
|
1402
|
+
/**
|
|
1403
|
+
* People who voted, each counted once even with several answers.
|
|
1404
|
+
*/
|
|
1405
|
+
total_voters: number | null;
|
|
1406
|
+
/**
|
|
1407
|
+
* Indexes of the options the user voted for; empty when they have not voted.
|
|
1408
|
+
*/
|
|
1409
|
+
my_votes: number[];
|
|
1410
|
+
/**
|
|
1411
|
+
* The user may close the poll now.
|
|
1412
|
+
*/
|
|
1413
|
+
can_close: boolean;
|
|
1414
|
+
/**
|
|
1415
|
+
* Grows with every vote and when the poll closes; keep the poll with the highest version.
|
|
1416
|
+
*/
|
|
1417
|
+
version: number;
|
|
1418
|
+
}
|
|
1188
1419
|
/**
|
|
1189
1420
|
* A user came online or went offline, as far as their privacy settings allow.
|
|
1190
1421
|
*/
|