@myronsi/messenger-api 2.1.0-alpha.36.next.127 → 2.1.0-alpha.37

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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Contract changes only. The backend changelog is `CHANGELOG.md` in the repository root. Rules: `docs/api-compatibility.md`.
4
4
 
5
+ ## 2.1.0-alpha.37
6
+
7
+ - `AccountStatus` gains the optional `decided_by` (`AccountStatusDecidedBy`: `automatic`, `staff`), `reason_code`
8
+ (`ModerationReason`: `spam`, `scam`, `harassment`, `impersonation`, `inappropriate_profile`, `illegal`, `other`) and
9
+ `reason_text` for statuses a person on the moderation team set. `can_appeal` is `false` for those.
10
+ - Reporter outcome notices: `GET /me/report-outcomes` (`ReportOutcomeList` of `ReportOutcome`: `ReportSubjectType`,
11
+ `ReportOutcomeKind`) and `POST /me/report-outcomes/{outcome_id}/read`; the WebSocket event `report_outcome` carries a
12
+ new one to the reporter's own sessions.
13
+
5
14
  ## 2.1.0-alpha.36
6
15
 
7
16
  - User reports: `POST /users/{user_id}/report` (`ReportUserRequest`: `ReportReason`, optional `note`, `block`
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.36. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.36";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.37. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.37";
3
3
  export type { paths, components, operations } from "./schema.js";
4
4
  export * from "./ws-events.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export const API_VERSION = "2.1.0-alpha.36";
1
+ export const API_VERSION = "2.1.0-alpha.37";
package/dist/openapi.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: Messenger API
4
- version: 2.1.0-alpha.36
4
+ version: 2.1.0-alpha.37
5
5
  summary: REST contract of the Messenger backend (v2).
6
6
  description: |
7
7
  Contract for the Go backend. The WebSocket protocol is described in `websocket/` and
@@ -1144,7 +1144,8 @@ paths:
1144
1144
  operationId: getAccountStatus
1145
1145
  summary: The current user's account status
1146
1146
  description: |
1147
- The status follows the reports on the account automatically (`docs/moderation.md`). `restrictions` lists
1147
+ The status follows the reports on the account automatically (`docs/moderation.md`), unless a person on the
1148
+ moderation team decided it (`decided_by: staff`, with `reason_code` and `reason_text`). `restrictions` lists
1148
1149
  what the status blocks. The WebSocket event `account_status` carries the same object when it changes.
1149
1150
  responses:
1150
1151
  "426": { $ref: "#/components/responses/ClientOutdated" }
@@ -1177,6 +1178,44 @@ paths:
1177
1178
  schema: { $ref: "#/components/schemas/AccountStatus" }
1178
1179
  "401": { $ref: "#/components/responses/Unauthorized" }
1179
1180
  "409": { $ref: "#/components/responses/Conflict" }
1181
+ /me/report-outcomes:
1182
+ parameters:
1183
+ - $ref: "#/components/parameters/ClientVersion"
1184
+ - $ref: "#/components/parameters/ClientApiVersion"
1185
+ get:
1186
+ tags: [me]
1187
+ operationId: listReportOutcomes
1188
+ summary: Outcomes of the current user's reports
1189
+ description: |
1190
+ Short notices about reports the current user made: the moderation team took action or found no violation.
1191
+ They never say what action was taken. Newest first, at most 50, kept for 90 days. A new one also arrives as
1192
+ the WebSocket event `report_outcome`.
1193
+ responses:
1194
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1195
+ "400": { $ref: "#/components/responses/BadRequest" }
1196
+ "200":
1197
+ description: The report outcomes
1198
+ content:
1199
+ application/json:
1200
+ schema: { $ref: "#/components/schemas/ReportOutcomeList" }
1201
+ "401": { $ref: "#/components/responses/Unauthorized" }
1202
+ /me/report-outcomes/{outcome_id}/read:
1203
+ parameters:
1204
+ - $ref: "#/components/parameters/ClientVersion"
1205
+ - $ref: "#/components/parameters/ClientApiVersion"
1206
+ - $ref: "#/components/parameters/ReportOutcomeId"
1207
+ post:
1208
+ tags: [me]
1209
+ operationId: markReportOutcomeRead
1210
+ summary: Mark a report outcome as read
1211
+ description: Marking an outcome that is already read is fine.
1212
+ responses:
1213
+ "426": { $ref: "#/components/responses/ClientOutdated" }
1214
+ "400": { $ref: "#/components/responses/BadRequest" }
1215
+ "204":
1216
+ description: Marked as read
1217
+ "401": { $ref: "#/components/responses/Unauthorized" }
1218
+ "404": { $ref: "#/components/responses/NotFound" }
1180
1219
  /users/{user_id}/avatar:
1181
1220
  parameters:
1182
1221
  - $ref: "#/components/parameters/ClientVersion"
@@ -5275,6 +5314,11 @@ components:
5275
5314
  in: path
5276
5315
  required: true
5277
5316
  schema: { $ref: "#/components/schemas/Id" }
5317
+ ReportOutcomeId:
5318
+ name: outcome_id
5319
+ in: path
5320
+ required: true
5321
+ schema: { $ref: "#/components/schemas/Id" }
5278
5322
  RequestId:
5279
5323
  name: request_id
5280
5324
  in: path
@@ -6166,6 +6210,58 @@ components:
6166
6210
  oneOf:
6167
6211
  - $ref: "#/components/schemas/Timestamp"
6168
6212
  - type: "null"
6213
+ decided_by:
6214
+ $ref: "#/components/schemas/AccountStatusDecidedBy"
6215
+ reason_code:
6216
+ description: The guideline rule a person on the moderation team named; `null` for automatic statuses.
6217
+ oneOf:
6218
+ - $ref: "#/components/schemas/ModerationReason"
6219
+ - type: "null"
6220
+ reason_text:
6221
+ type: [string, "null"]
6222
+ maxLength: 1000
6223
+ description: |
6224
+ The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as
6225
+ written by "Messenger moderation", never by a person's name.
6226
+ AccountStatusDecidedBy:
6227
+ type: string
6228
+ description: |
6229
+ Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the
6230
+ moderation team). Missing means `automatic`. Unknown values must be treated like `automatic`.
6231
+ enum: [automatic, staff]
6232
+ ModerationReason:
6233
+ type: string
6234
+ description: The guideline rule behind a moderation decision. Unknown values must be shown as `other`.
6235
+ enum: [spam, scam, harassment, impersonation, inappropriate_profile, illegal, other]
6236
+ ReportOutcomeKind:
6237
+ type: string
6238
+ description: |
6239
+ `action_taken` the moderation team acted on the report, `no_violation` it found no violation. Unknown values
6240
+ must be shown as a generic "your report was reviewed".
6241
+ enum: [action_taken, no_violation]
6242
+ ReportSubjectType:
6243
+ type: string
6244
+ description: What was reported. Unknown values must be shown without the subject.
6245
+ enum: [user, sticker_pack, emoji_pack]
6246
+ ReportOutcome:
6247
+ type: object
6248
+ required: [id, subject_type, subject_id, outcome, created_at, read]
6249
+ properties:
6250
+ id: { $ref: "#/components/schemas/Id" }
6251
+ subject_type: { $ref: "#/components/schemas/ReportSubjectType" }
6252
+ subject_id:
6253
+ allOf: [{ $ref: "#/components/schemas/Id" }]
6254
+ description: The reported user, sticker pack or emoji pack.
6255
+ outcome: { $ref: "#/components/schemas/ReportOutcomeKind" }
6256
+ created_at: { $ref: "#/components/schemas/Timestamp" }
6257
+ read: { type: boolean }
6258
+ ReportOutcomeList:
6259
+ type: object
6260
+ required: [items]
6261
+ properties:
6262
+ items:
6263
+ type: array
6264
+ items: { $ref: "#/components/schemas/ReportOutcome" }
6169
6265
  Me:
6170
6266
  allOf:
6171
6267
  - $ref: "#/components/schemas/User"
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.36. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.37. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -993,7 +993,8 @@ export interface paths {
993
993
  };
994
994
  /**
995
995
  * The current user's account status
996
- * @description The status follows the reports on the account automatically (`docs/moderation.md`). `restrictions` lists
996
+ * @description The status follows the reports on the account automatically (`docs/moderation.md`), unless a person on the
997
+ * moderation team decided it (`decided_by: staff`, with `reason_code` and `reason_text`). `restrictions` lists
997
998
  * what the status blocks. The WebSocket event `account_status` carries the same object when it changes.
998
999
  */
999
1000
  get: operations["getAccountStatus"];
@@ -1032,6 +1033,60 @@ export interface paths {
1032
1033
  patch?: never;
1033
1034
  trace?: never;
1034
1035
  };
1036
+ "/me/report-outcomes": {
1037
+ parameters: {
1038
+ query?: never;
1039
+ header?: {
1040
+ /** @description Version of the client app, for logs and the per-client metric. */
1041
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1042
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
1043
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1044
+ };
1045
+ path?: never;
1046
+ cookie?: never;
1047
+ };
1048
+ /**
1049
+ * Outcomes of the current user's reports
1050
+ * @description Short notices about reports the current user made: the moderation team took action or found no violation.
1051
+ * They never say what action was taken. Newest first, at most 50, kept for 90 days. A new one also arrives as
1052
+ * the WebSocket event `report_outcome`.
1053
+ */
1054
+ get: operations["listReportOutcomes"];
1055
+ put?: never;
1056
+ post?: never;
1057
+ delete?: never;
1058
+ options?: never;
1059
+ head?: never;
1060
+ patch?: never;
1061
+ trace?: never;
1062
+ };
1063
+ "/me/report-outcomes/{outcome_id}/read": {
1064
+ parameters: {
1065
+ query?: never;
1066
+ header?: {
1067
+ /** @description Version of the client app, for logs and the per-client metric. */
1068
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1069
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
1070
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1071
+ };
1072
+ path: {
1073
+ outcome_id: components["parameters"]["ReportOutcomeId"];
1074
+ };
1075
+ cookie?: never;
1076
+ };
1077
+ get?: never;
1078
+ put?: never;
1079
+ /**
1080
+ * Mark a report outcome as read
1081
+ * @description Marking an outcome that is already read is fine.
1082
+ */
1083
+ post: operations["markReportOutcomeRead"];
1084
+ delete?: never;
1085
+ options?: never;
1086
+ head?: never;
1087
+ patch?: never;
1088
+ trace?: never;
1089
+ };
1035
1090
  "/users/{user_id}/avatar": {
1036
1091
  parameters: {
1037
1092
  query?: never;
@@ -4335,6 +4390,48 @@ export interface components {
4335
4390
  can_appeal: boolean;
4336
4391
  /** @description End of the running probation after an appeal; `null` when none runs. */
4337
4392
  probation_until: components["schemas"]["Timestamp"] | null;
4393
+ decided_by?: components["schemas"]["AccountStatusDecidedBy"];
4394
+ /** @description The guideline rule a person on the moderation team named; `null` for automatic statuses. */
4395
+ reason_code?: components["schemas"]["ModerationReason"] | null;
4396
+ /**
4397
+ * @description The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as
4398
+ * written by "Messenger moderation", never by a person's name.
4399
+ */
4400
+ reason_text?: string | null;
4401
+ };
4402
+ /**
4403
+ * @description Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the
4404
+ * moderation team). Missing means `automatic`. Unknown values must be treated like `automatic`.
4405
+ * @enum {string}
4406
+ */
4407
+ AccountStatusDecidedBy: "automatic" | "staff";
4408
+ /**
4409
+ * @description The guideline rule behind a moderation decision. Unknown values must be shown as `other`.
4410
+ * @enum {string}
4411
+ */
4412
+ ModerationReason: "spam" | "scam" | "harassment" | "impersonation" | "inappropriate_profile" | "illegal" | "other";
4413
+ /**
4414
+ * @description `action_taken` the moderation team acted on the report, `no_violation` it found no violation. Unknown values
4415
+ * must be shown as a generic "your report was reviewed".
4416
+ * @enum {string}
4417
+ */
4418
+ ReportOutcomeKind: "action_taken" | "no_violation";
4419
+ /**
4420
+ * @description What was reported. Unknown values must be shown without the subject.
4421
+ * @enum {string}
4422
+ */
4423
+ ReportSubjectType: "user" | "sticker_pack" | "emoji_pack";
4424
+ ReportOutcome: {
4425
+ id: components["schemas"]["Id"];
4426
+ subject_type: components["schemas"]["ReportSubjectType"];
4427
+ /** @description The reported user, sticker pack or emoji pack. */
4428
+ subject_id: components["schemas"]["Id"];
4429
+ outcome: components["schemas"]["ReportOutcomeKind"];
4430
+ created_at: components["schemas"]["Timestamp"];
4431
+ read: boolean;
4432
+ };
4433
+ ReportOutcomeList: {
4434
+ items: components["schemas"]["ReportOutcome"][];
4338
4435
  };
4339
4436
  Me: components["schemas"]["User"] & {
4340
4437
  created_at: components["schemas"]["Timestamp"];
@@ -5411,6 +5508,7 @@ export interface components {
5411
5508
  ChatId: components["schemas"]["Id"];
5412
5509
  MessageId: components["schemas"]["Id"];
5413
5510
  UserId: components["schemas"]["Id"];
5511
+ ReportOutcomeId: components["schemas"]["Id"];
5414
5512
  RequestId: components["schemas"]["Id"];
5415
5513
  AttachmentId: components["schemas"]["AttachmentRef"];
5416
5514
  UploadId: string;
@@ -7056,6 +7154,63 @@ export interface operations {
7056
7154
  426: components["responses"]["ClientOutdated"];
7057
7155
  };
7058
7156
  };
7157
+ listReportOutcomes: {
7158
+ parameters: {
7159
+ query?: never;
7160
+ header?: {
7161
+ /** @description Version of the client app, for logs and the per-client metric. */
7162
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
7163
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
7164
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
7165
+ };
7166
+ path?: never;
7167
+ cookie?: never;
7168
+ };
7169
+ requestBody?: never;
7170
+ responses: {
7171
+ /** @description The report outcomes */
7172
+ 200: {
7173
+ headers: {
7174
+ [name: string]: unknown;
7175
+ };
7176
+ content: {
7177
+ "application/json": components["schemas"]["ReportOutcomeList"];
7178
+ };
7179
+ };
7180
+ 400: components["responses"]["BadRequest"];
7181
+ 401: components["responses"]["Unauthorized"];
7182
+ 426: components["responses"]["ClientOutdated"];
7183
+ };
7184
+ };
7185
+ markReportOutcomeRead: {
7186
+ parameters: {
7187
+ query?: never;
7188
+ header?: {
7189
+ /** @description Version of the client app, for logs and the per-client metric. */
7190
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
7191
+ /** @description Contract version the client was built with (`API_VERSION` of `@myronsi/messenger-api`). A different MAJOR or a version below `min_client_api_version` is answered with `426`; a malformed value with `400` (`invalid_client_version`). */
7192
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
7193
+ };
7194
+ path: {
7195
+ outcome_id: components["parameters"]["ReportOutcomeId"];
7196
+ };
7197
+ cookie?: never;
7198
+ };
7199
+ requestBody?: never;
7200
+ responses: {
7201
+ /** @description Marked as read */
7202
+ 204: {
7203
+ headers: {
7204
+ [name: string]: unknown;
7205
+ };
7206
+ content?: never;
7207
+ };
7208
+ 400: components["responses"]["BadRequest"];
7209
+ 401: components["responses"]["Unauthorized"];
7210
+ 404: components["responses"]["NotFound"];
7211
+ 426: components["responses"]["ClientOutdated"];
7212
+ };
7213
+ };
7059
7214
  getUserAvatar: {
7060
7215
  parameters: {
7061
7216
  query?: {
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 |\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| `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| `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 |\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| `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",
@@ -75,15 +75,24 @@
75
75
  "event_id": "7217400317439950011",
76
76
  "chat_id": null,
77
77
  "data": {
78
- "status": "limited",
78
+ "status": "restricted",
79
79
  "since": "2026-11-18T09:30:00Z",
80
80
  "restrictions": [
81
81
  "start_direct",
82
82
  "invite_to_group",
83
- "call"
83
+ "call",
84
+ "create_group",
85
+ "upload",
86
+ "forward",
87
+ "edit_profile",
88
+ "publish_pack",
89
+ "search"
84
90
  ],
85
- "can_appeal": true,
86
- "probation_until": null
91
+ "can_appeal": false,
92
+ "probation_until": null,
93
+ "decided_by": "staff",
94
+ "reason_code": "spam",
95
+ "reason_text": "Your account sent the same advertising link to many people who did not know you."
87
96
  }
88
97
  },
89
98
  "server/ack.json": {
@@ -604,6 +613,19 @@
604
613
  "expires_at": "2026-11-05T20:00:00Z"
605
614
  }
606
615
  },
616
+ "server/report_outcome.json": {
617
+ "type": "report_outcome",
618
+ "event_id": "7217400317439950012",
619
+ "chat_id": null,
620
+ "data": {
621
+ "id": "41",
622
+ "subject_type": "user",
623
+ "subject_id": "7217400317439950848",
624
+ "outcome": "action_taken",
625
+ "created_at": "2026-11-19T10:15:00Z",
626
+ "read": false
627
+ }
628
+ },
607
629
  "server/security_alert.json": {
608
630
  "type": "security_alert",
609
631
  "event_id": "7217400317439950010",
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.36. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.37. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -54,6 +54,7 @@ export type ServerEvent =
54
54
  | ServerReactionRemoveEvent
55
55
  | ServerReadEvent
56
56
  | ServerRecoveryRequestEvent
57
+ | ServerReportOutcomeEvent
57
58
  | ServerSecurityAlertEvent
58
59
  | ServerSecurityNoticeEvent
59
60
  | ServerTypingEvent
@@ -82,6 +83,17 @@ export type AccountRestriction =
82
83
  | "search"
83
84
  | "send"
84
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";
85
97
  export type ApprovalRequestType = "direct_message" | "group_invite";
86
98
  export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
87
99
  export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
@@ -164,6 +176,16 @@ export type ErrorCode =
164
176
  | "limit_reached"
165
177
  | "account_restricted"
166
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";
167
189
 
168
190
  /**
169
191
  * Delete a message for yourself or for everyone.
@@ -303,6 +325,17 @@ export interface AccountStatus {
303
325
  * End of the running probation after an appeal; `null` when none runs.
304
326
  */
305
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;
306
339
  }
307
340
  /**
308
341
  * The server accepted the client event with this `client_temp_id`.
@@ -1087,6 +1120,26 @@ export interface Location {
1087
1120
  */
1088
1121
  country: string | null;
1089
1122
  }
1123
+ /**
1124
+ * The moderation team reviewed something the current user reported (sent only to the reporter's own sessions).
1125
+ */
1126
+ export interface ServerReportOutcomeEvent {
1127
+ type: "report_outcome";
1128
+ event_id: Id;
1129
+ chat_id: null;
1130
+ data: ReportOutcome;
1131
+ }
1132
+ export interface ReportOutcome {
1133
+ id: Id;
1134
+ subject_type: ReportSubjectType;
1135
+ /**
1136
+ * The reported user, sticker pack or emoji pack.
1137
+ */
1138
+ subject_id: Id;
1139
+ outcome: ReportOutcomeKind;
1140
+ created_at: Timestamp;
1141
+ read: boolean;
1142
+ }
1090
1143
  export interface ServerSecurityAlertEvent {
1091
1144
  type: "security_alert";
1092
1145
  event_id: Id;
@@ -1492,6 +1492,116 @@
1492
1492
  "type": "null"
1493
1493
  }
1494
1494
  ]
1495
+ },
1496
+ "decided_by": {
1497
+ "$ref": "#/$defs/AccountStatusDecidedBy"
1498
+ },
1499
+ "reason_code": {
1500
+ "description": "The guideline rule a person on the moderation team named; `null` for automatic statuses.",
1501
+ "oneOf": [
1502
+ {
1503
+ "$ref": "#/$defs/ModerationReason"
1504
+ },
1505
+ {
1506
+ "type": "null"
1507
+ }
1508
+ ]
1509
+ },
1510
+ "reason_text": {
1511
+ "type": [
1512
+ "string",
1513
+ "null"
1514
+ ],
1515
+ "maxLength": 1000,
1516
+ "description": "The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as\nwritten by \"Messenger moderation\", never by a person's name.\n"
1517
+ }
1518
+ }
1519
+ },
1520
+ "AccountStatusDecidedBy": {
1521
+ "type": "string",
1522
+ "description": "Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the\nmoderation team). Missing means `automatic`. Unknown values must be treated like `automatic`.\n",
1523
+ "enum": [
1524
+ "automatic",
1525
+ "staff"
1526
+ ]
1527
+ },
1528
+ "ModerationReason": {
1529
+ "type": "string",
1530
+ "description": "The guideline rule behind a moderation decision. Unknown values must be shown as `other`.",
1531
+ "enum": [
1532
+ "spam",
1533
+ "scam",
1534
+ "harassment",
1535
+ "impersonation",
1536
+ "inappropriate_profile",
1537
+ "illegal",
1538
+ "other"
1539
+ ]
1540
+ },
1541
+ "ReportOutcomeKind": {
1542
+ "type": "string",
1543
+ "description": "`action_taken` the moderation team acted on the report, `no_violation` it found no violation. Unknown values\nmust be shown as a generic \"your report was reviewed\".\n",
1544
+ "enum": [
1545
+ "action_taken",
1546
+ "no_violation"
1547
+ ]
1548
+ },
1549
+ "ReportSubjectType": {
1550
+ "type": "string",
1551
+ "description": "What was reported. Unknown values must be shown without the subject.",
1552
+ "enum": [
1553
+ "user",
1554
+ "sticker_pack",
1555
+ "emoji_pack"
1556
+ ]
1557
+ },
1558
+ "ReportOutcome": {
1559
+ "type": "object",
1560
+ "required": [
1561
+ "id",
1562
+ "subject_type",
1563
+ "subject_id",
1564
+ "outcome",
1565
+ "created_at",
1566
+ "read"
1567
+ ],
1568
+ "properties": {
1569
+ "id": {
1570
+ "$ref": "#/$defs/Id"
1571
+ },
1572
+ "subject_type": {
1573
+ "$ref": "#/$defs/ReportSubjectType"
1574
+ },
1575
+ "subject_id": {
1576
+ "allOf": [
1577
+ {
1578
+ "$ref": "#/$defs/Id"
1579
+ }
1580
+ ],
1581
+ "description": "The reported user, sticker pack or emoji pack."
1582
+ },
1583
+ "outcome": {
1584
+ "$ref": "#/$defs/ReportOutcomeKind"
1585
+ },
1586
+ "created_at": {
1587
+ "$ref": "#/$defs/Timestamp"
1588
+ },
1589
+ "read": {
1590
+ "type": "boolean"
1591
+ }
1592
+ }
1593
+ },
1594
+ "ReportOutcomeList": {
1595
+ "type": "object",
1596
+ "required": [
1597
+ "items"
1598
+ ],
1599
+ "properties": {
1600
+ "items": {
1601
+ "type": "array",
1602
+ "items": {
1603
+ "$ref": "#/$defs/ReportOutcome"
1604
+ }
1495
1605
  }
1496
1606
  }
1497
1607
  },
@@ -6241,6 +6351,31 @@
6241
6351
  }
6242
6352
  }
6243
6353
  },
6354
+ "ServerReportOutcomeEvent": {
6355
+ "title": "ServerReportOutcomeEvent",
6356
+ "description": "The moderation team reviewed something the current user reported (sent only to the reporter's own sessions).",
6357
+ "type": "object",
6358
+ "required": [
6359
+ "type",
6360
+ "event_id",
6361
+ "chat_id",
6362
+ "data"
6363
+ ],
6364
+ "properties": {
6365
+ "type": {
6366
+ "const": "report_outcome"
6367
+ },
6368
+ "event_id": {
6369
+ "$ref": "#/$defs/Id"
6370
+ },
6371
+ "chat_id": {
6372
+ "type": "null"
6373
+ },
6374
+ "data": {
6375
+ "$ref": "#/$defs/ReportOutcome"
6376
+ }
6377
+ }
6378
+ },
6244
6379
  "ServerSecurityAlertEvent": {
6245
6380
  "title": "ServerSecurityAlertEvent",
6246
6381
  "type": "object",
@@ -6521,6 +6656,9 @@
6521
6656
  {
6522
6657
  "$ref": "#/$defs/ServerRecoveryRequestEvent"
6523
6658
  },
6659
+ {
6660
+ "$ref": "#/$defs/ServerReportOutcomeEvent"
6661
+ },
6524
6662
  {
6525
6663
  "$ref": "#/$defs/ServerSecurityAlertEvent"
6526
6664
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.36.next.127",
3
+ "version": "2.1.0-alpha.37",
4
4
  "description": "API contract of the Messenger backend: OpenAPI document, WebSocket event schemas and generated TypeScript types",
5
5
  "license": "MIT",
6
6
  "repository": {