@myronsi/messenger-api 2.1.0-alpha.46.next.165 → 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 +16 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +472 -19
- package/dist/schema.d.ts +557 -21
- package/dist/ws-docs.json +34 -1
- package/dist/ws-events.d.ts +152 -9
- package/dist/ws-events.schema.json +574 -18
- 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| `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",
|
|
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",
|
|
@@ -593,6 +593,39 @@
|
|
|
593
593
|
"at": "2026-11-21T10:15:00Z"
|
|
594
594
|
}
|
|
595
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
|
+
},
|
|
596
629
|
"server/presence.json": {
|
|
597
630
|
"type": "presence",
|
|
598
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.
|
|
@@ -52,6 +52,7 @@ export type ServerEvent =
|
|
|
52
52
|
| ServerImportUpdateEvent
|
|
53
53
|
| ServerMessageEvent
|
|
54
54
|
| ServerPinUpdateEvent
|
|
55
|
+
| ServerPollUpdatedEvent
|
|
55
56
|
| ServerPresenceEvent
|
|
56
57
|
| ServerReactionAddEvent
|
|
57
58
|
| ServerReactionRemoveEvent
|
|
@@ -137,7 +138,13 @@ export type CallParticipantState = "ringing" | "joined" | "declined" | "missed"
|
|
|
137
138
|
*/
|
|
138
139
|
export type CallIdentityKey = string;
|
|
139
140
|
export type ChatType = "direct" | "group";
|
|
140
|
-
|
|
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";
|
|
141
148
|
export type StickerPackSlug = string;
|
|
142
149
|
export type ImportSource = "telegram" | "whatsapp";
|
|
143
150
|
export type SystemEventKind =
|
|
@@ -151,7 +158,10 @@ export type SystemEventKind =
|
|
|
151
158
|
| "message_unpinned"
|
|
152
159
|
| "history_imported"
|
|
153
160
|
| "history_import_ended"
|
|
154
|
-
| "imported_note"
|
|
161
|
+
| "imported_note"
|
|
162
|
+
| "group_renamed"
|
|
163
|
+
| "group_avatar_changed"
|
|
164
|
+
| "owner_transferred";
|
|
155
165
|
/**
|
|
156
166
|
* A moderator may delete other members' messages; owners and admins also manage the group.
|
|
157
167
|
*/
|
|
@@ -192,6 +202,8 @@ export type ErrorCode =
|
|
|
192
202
|
| "stale_epoch"
|
|
193
203
|
| "limit_reached"
|
|
194
204
|
| "account_restricted"
|
|
205
|
+
| "poll_closed"
|
|
206
|
+
| "quiz_answered"
|
|
195
207
|
| "internal_error";
|
|
196
208
|
/**
|
|
197
209
|
* A username or a group's public name. One name space for both, unique ignoring case; links are `/@name` on the
|
|
@@ -811,7 +823,9 @@ export interface Message {
|
|
|
811
823
|
*/
|
|
812
824
|
sender: User | null;
|
|
813
825
|
/**
|
|
814
|
-
* 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
|
+
*
|
|
815
829
|
*/
|
|
816
830
|
content: string | null;
|
|
817
831
|
attachment: Attachment | null;
|
|
@@ -901,6 +915,9 @@ export interface Message {
|
|
|
901
915
|
* `true` when an owner or admin wrote `@all`; it mentions every member. Absent otherwise.
|
|
902
916
|
*/
|
|
903
917
|
mentions_all?: boolean;
|
|
918
|
+
poll?: Poll;
|
|
919
|
+
contact?: ContactCard;
|
|
920
|
+
location?: MessageLocation;
|
|
904
921
|
}
|
|
905
922
|
/**
|
|
906
923
|
* What a reply shows of the message it answers, so a client can draw the quote without loading that
|
|
@@ -998,9 +1015,11 @@ export interface ModerationRemovalReason {
|
|
|
998
1015
|
}
|
|
999
1016
|
/**
|
|
1000
1017
|
* What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
1001
|
-
* are the display names at the time of the event. `target` fields are set for `member_added
|
|
1002
|
-
* `member_removed
|
|
1003
|
-
*
|
|
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`.
|
|
1004
1023
|
* `history_imported` opens and `history_import_ended` closes an imported history; both carry `import`, and
|
|
1005
1024
|
* `actor` is the importer. `imported_note` is a line of the export that is not a message; its text is `text`.
|
|
1006
1025
|
*
|
|
@@ -1017,12 +1036,19 @@ export interface SystemEvent {
|
|
|
1017
1036
|
*/
|
|
1018
1037
|
message_id?: Id;
|
|
1019
1038
|
/**
|
|
1020
|
-
* Start of the pinned message's text at the time of the event (at most 60 characters plus `…`)
|
|
1021
|
-
* 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`.
|
|
1022
1042
|
*
|
|
1023
1043
|
*/
|
|
1024
1044
|
snippet?: string;
|
|
1025
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;
|
|
1026
1052
|
import?: ImportSummary;
|
|
1027
1053
|
/**
|
|
1028
1054
|
* The line of the export, for `imported_note`.
|
|
@@ -1048,6 +1074,76 @@ export interface ImportSummary {
|
|
|
1048
1074
|
first_at: Timestamp;
|
|
1049
1075
|
last_at: Timestamp;
|
|
1050
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
|
+
}
|
|
1051
1147
|
/**
|
|
1052
1148
|
* A chat was deleted, or you were removed from it.
|
|
1053
1149
|
*/
|
|
@@ -1273,6 +1369,53 @@ export interface ServerPinUpdateEvent {
|
|
|
1273
1369
|
pinned_message_count?: number;
|
|
1274
1370
|
};
|
|
1275
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
|
+
}
|
|
1276
1419
|
/**
|
|
1277
1420
|
* A user came online or went offline, as far as their privacy settings allow.
|
|
1278
1421
|
*/
|