@myronsi/messenger-api 2.1.0-alpha.38.next.135 → 2.1.0-alpha.39

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.39
6
+
7
+ - Content reports: `POST /chats/{chat_id}/messages/{message_id}/report` and `POST /groups/{chat_id}/report`
8
+ (`ContentReportRequest`: `ContentReportReason`, which adds `illegal` with a required `note`), and `DELETE` on both
9
+ to withdraw. User, message and group reports share the limit of 20 a day.
10
+ - `Message.removed_by_moderation` and, for the sender only, `Message.moderation_reason` (`ModerationRemovalReason`:
11
+ a `ModerationReason` `code` and a `text`); `ReplyPreview.removed_by_moderation`. The WebSocket `delete` event gains
12
+ the optional `removed_by_moderation` and, in the sender's copy, `moderation_reason`.
13
+
5
14
  ## 2.1.0-alpha.38
6
15
 
7
16
  - Review by a person: `POST /me/account-status/review` (`AccountReviewRequest`: `text`, 1 to 500 characters) stores a
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.38. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.38";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.39. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.39";
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.38";
1
+ export const API_VERSION = "2.1.0-alpha.39";
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.38
4
+ version: 2.1.0-alpha.39
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
@@ -2194,6 +2194,50 @@ paths:
2194
2194
  "404": { $ref: "#/components/responses/NotFound" }
2195
2195
  "422": { $ref: "#/components/responses/ValidationFailed" }
2196
2196
  "429": { $ref: "#/components/responses/TooManyRequests" }
2197
+ /chats/{chat_id}/messages/{message_id}/report:
2198
+ parameters:
2199
+ - $ref: "#/components/parameters/ClientVersion"
2200
+ - $ref: "#/components/parameters/ClientApiVersion"
2201
+ - $ref: "#/components/parameters/ChatId"
2202
+ - $ref: "#/components/parameters/MessageId"
2203
+ post:
2204
+ tags: [messages]
2205
+ operationId: reportMessage
2206
+ summary: Report a message
2207
+ description: |
2208
+ Sends the message to moderation. The report keeps a copy of the message and of up to 5 messages before and
2209
+ after it that the reporter can see (sender, time, text and file names); moderators see only this copy, and it
2210
+ is deleted after 6 months. One active report per reporter and message; reporting again changes the reason
2211
+ and the note but keeps the first copy. `illegal` is a notice of illegal content and needs a `note` that
2212
+ explains why (`422` without it). A message the caller cannot see, a deleted message or a chat they are not in
2213
+ is `404`; their own messages and system messages are `422`. Reports of users, messages and groups share the
2214
+ limit of 20 a day (`429`). Reporting a message does not block anyone and does not change the sender's
2215
+ account status.
2216
+ requestBody:
2217
+ required: true
2218
+ content:
2219
+ application/json:
2220
+ schema: { $ref: "#/components/schemas/ContentReportRequest" }
2221
+ responses:
2222
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2223
+ "400": { $ref: "#/components/responses/BadRequest" }
2224
+ "204":
2225
+ description: Reported
2226
+ "401": { $ref: "#/components/responses/Unauthorized" }
2227
+ "404": { $ref: "#/components/responses/NotFound" }
2228
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2229
+ "429": { $ref: "#/components/responses/TooManyRequests" }
2230
+ delete:
2231
+ tags: [messages]
2232
+ operationId: unreportMessage
2233
+ summary: Withdraw a message report
2234
+ description: Withdraws the current user's report on the message. Withdrawing a report that does not exist is fine.
2235
+ responses:
2236
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2237
+ "400": { $ref: "#/components/responses/BadRequest" }
2238
+ "204":
2239
+ description: Withdrawn
2240
+ "401": { $ref: "#/components/responses/Unauthorized" }
2197
2241
  /chats/{chat_id}/messages/forward:
2198
2242
  parameters:
2199
2243
  - $ref: "#/components/parameters/ClientVersion"
@@ -2687,6 +2731,46 @@ paths:
2687
2731
  "401": { $ref: "#/components/responses/Unauthorized" }
2688
2732
  "404": { $ref: "#/components/responses/NotFound" }
2689
2733
  "409": { $ref: "#/components/responses/Conflict" }
2734
+ /groups/{chat_id}/report:
2735
+ parameters:
2736
+ - $ref: "#/components/parameters/ClientVersion"
2737
+ - $ref: "#/components/parameters/ClientApiVersion"
2738
+ - $ref: "#/components/parameters/ChatId"
2739
+ post:
2740
+ tags: [groups]
2741
+ operationId: reportGroup
2742
+ summary: Report a group
2743
+ description: |
2744
+ Sends the group to moderation for its name, description or picture. The report keeps a copy of them; it is
2745
+ deleted after 6 months. Only members can report a group (`404` otherwise, also for direct chats). One active
2746
+ report per reporter and group; reporting again changes the reason and the note but keeps the first copy.
2747
+ `illegal` needs a `note` (`422` without it). Shares the limit of 20 reports a day with user and message
2748
+ reports (`429`).
2749
+ requestBody:
2750
+ required: true
2751
+ content:
2752
+ application/json:
2753
+ schema: { $ref: "#/components/schemas/ContentReportRequest" }
2754
+ responses:
2755
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2756
+ "400": { $ref: "#/components/responses/BadRequest" }
2757
+ "204":
2758
+ description: Reported
2759
+ "401": { $ref: "#/components/responses/Unauthorized" }
2760
+ "404": { $ref: "#/components/responses/NotFound" }
2761
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2762
+ "429": { $ref: "#/components/responses/TooManyRequests" }
2763
+ delete:
2764
+ tags: [groups]
2765
+ operationId: unreportGroup
2766
+ summary: Withdraw a group report
2767
+ description: Withdraws the current user's report on the group. Withdrawing a report that does not exist is fine.
2768
+ responses:
2769
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2770
+ "400": { $ref: "#/components/responses/BadRequest" }
2771
+ "204":
2772
+ description: Withdrawn
2773
+ "401": { $ref: "#/components/responses/Unauthorized" }
2690
2774
  /groups/{chat_id}/role-log:
2691
2775
  parameters:
2692
2776
  - $ref: "#/components/parameters/ClientVersion"
@@ -6210,6 +6294,34 @@ components:
6210
6294
  default: true
6211
6295
  description: Also block the user.
6212
6296
  additionalProperties: false
6297
+ ContentReportReason:
6298
+ type: string
6299
+ description: The reasons of `ReportReason` plus `illegal`, a notice of illegal content.
6300
+ enum: [spam, scam, harassment, impersonation, inappropriate_profile, illegal, other]
6301
+ ContentReportRequest:
6302
+ type: object
6303
+ required: [reason]
6304
+ properties:
6305
+ reason: { $ref: "#/components/schemas/ContentReportReason" }
6306
+ note:
6307
+ type: [string, "null"]
6308
+ maxLength: 1000
6309
+ description: |
6310
+ Details for moderation, never shown to the sender or the group. Required for `illegal`: why the content is
6311
+ illegal, for example which law it breaks.
6312
+ additionalProperties: false
6313
+ ModerationRemovalReason:
6314
+ type: object
6315
+ description: Why moderation removed something, shown only to its author.
6316
+ required: [code, text]
6317
+ properties:
6318
+ code: { $ref: "#/components/schemas/ModerationReason" }
6319
+ text:
6320
+ type: string
6321
+ maxLength: 1000
6322
+ description: |
6323
+ A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
6324
+ never by a person's name.
6213
6325
  AccountStatusLevel:
6214
6326
  type: string
6215
6327
  description: |
@@ -6919,6 +7031,9 @@ components:
6919
7031
  - $ref: "#/components/schemas/Attachment"
6920
7032
  - type: "null"
6921
7033
  is_deleted: { type: boolean }
7034
+ removed_by_moderation:
7035
+ type: boolean
7036
+ description: "`true` when moderation removed the answered message. Absent otherwise."
6922
7037
  Message:
6923
7038
  type: object
6924
7039
  required:
@@ -6985,6 +7100,14 @@ components:
6985
7100
  - $ref: "#/components/schemas/Timestamp"
6986
7101
  - type: "null"
6987
7102
  is_deleted: { type: boolean }
7103
+ removed_by_moderation:
7104
+ type: boolean
7105
+ description: |
7106
+ `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
7107
+ moderation" instead of the deleted placeholder. Absent otherwise.
7108
+ moderation_reason:
7109
+ allOf: [{ $ref: "#/components/schemas/ModerationRemovalReason" }]
7110
+ description: Why moderation removed the message; only for its sender, absent for everyone else.
6988
7111
  system_event:
6989
7112
  $ref: "#/components/schemas/SystemEvent"
6990
7113
  client_temp_id: { $ref: "#/components/schemas/ClientTempId" }
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.38. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.39. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -1879,6 +1879,45 @@ export interface paths {
1879
1879
  patch?: never;
1880
1880
  trace?: never;
1881
1881
  };
1882
+ "/chats/{chat_id}/messages/{message_id}/report": {
1883
+ parameters: {
1884
+ query?: never;
1885
+ header?: {
1886
+ /** @description Version of the client app, for logs and the per-client metric. */
1887
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
1888
+ /** @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`). */
1889
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
1890
+ };
1891
+ path: {
1892
+ chat_id: components["parameters"]["ChatId"];
1893
+ message_id: components["parameters"]["MessageId"];
1894
+ };
1895
+ cookie?: never;
1896
+ };
1897
+ get?: never;
1898
+ put?: never;
1899
+ /**
1900
+ * Report a message
1901
+ * @description Sends the message to moderation. The report keeps a copy of the message and of up to 5 messages before and
1902
+ * after it that the reporter can see (sender, time, text and file names); moderators see only this copy, and it
1903
+ * is deleted after 6 months. One active report per reporter and message; reporting again changes the reason
1904
+ * and the note but keeps the first copy. `illegal` is a notice of illegal content and needs a `note` that
1905
+ * explains why (`422` without it). A message the caller cannot see, a deleted message or a chat they are not in
1906
+ * is `404`; their own messages and system messages are `422`. Reports of users, messages and groups share the
1907
+ * limit of 20 a day (`429`). Reporting a message does not block anyone and does not change the sender's
1908
+ * account status.
1909
+ */
1910
+ post: operations["reportMessage"];
1911
+ /**
1912
+ * Withdraw a message report
1913
+ * @description Withdraws the current user's report on the message. Withdrawing a report that does not exist is fine.
1914
+ */
1915
+ delete: operations["unreportMessage"];
1916
+ options?: never;
1917
+ head?: never;
1918
+ patch?: never;
1919
+ trace?: never;
1920
+ };
1882
1921
  "/chats/{chat_id}/messages/forward": {
1883
1922
  parameters: {
1884
1923
  query?: never;
@@ -2257,6 +2296,41 @@ export interface paths {
2257
2296
  patch?: never;
2258
2297
  trace?: never;
2259
2298
  };
2299
+ "/groups/{chat_id}/report": {
2300
+ parameters: {
2301
+ query?: never;
2302
+ header?: {
2303
+ /** @description Version of the client app, for logs and the per-client metric. */
2304
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
2305
+ /** @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`). */
2306
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
2307
+ };
2308
+ path: {
2309
+ chat_id: components["parameters"]["ChatId"];
2310
+ };
2311
+ cookie?: never;
2312
+ };
2313
+ get?: never;
2314
+ put?: never;
2315
+ /**
2316
+ * Report a group
2317
+ * @description Sends the group to moderation for its name, description or picture. The report keeps a copy of them; it is
2318
+ * deleted after 6 months. Only members can report a group (`404` otherwise, also for direct chats). One active
2319
+ * report per reporter and group; reporting again changes the reason and the note but keeps the first copy.
2320
+ * `illegal` needs a `note` (`422` without it). Shares the limit of 20 reports a day with user and message
2321
+ * reports (`429`).
2322
+ */
2323
+ post: operations["reportGroup"];
2324
+ /**
2325
+ * Withdraw a group report
2326
+ * @description Withdraws the current user's report on the group. Withdrawing a report that does not exist is fine.
2327
+ */
2328
+ delete: operations["unreportGroup"];
2329
+ options?: never;
2330
+ head?: never;
2331
+ patch?: never;
2332
+ trace?: never;
2333
+ };
2260
2334
  "/groups/{chat_id}/role-log": {
2261
2335
  parameters: {
2262
2336
  query?: never;
@@ -4398,6 +4472,28 @@ export interface components {
4398
4472
  */
4399
4473
  block: boolean;
4400
4474
  };
4475
+ /**
4476
+ * @description The reasons of `ReportReason` plus `illegal`, a notice of illegal content.
4477
+ * @enum {string}
4478
+ */
4479
+ ContentReportReason: "spam" | "scam" | "harassment" | "impersonation" | "inappropriate_profile" | "illegal" | "other";
4480
+ ContentReportRequest: {
4481
+ reason: components["schemas"]["ContentReportReason"];
4482
+ /**
4483
+ * @description Details for moderation, never shown to the sender or the group. Required for `illegal`: why the content is
4484
+ * illegal, for example which law it breaks.
4485
+ */
4486
+ note?: string | null;
4487
+ };
4488
+ /** @description Why moderation removed something, shown only to its author. */
4489
+ ModerationRemovalReason: {
4490
+ code: components["schemas"]["ModerationReason"];
4491
+ /**
4492
+ * @description A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
4493
+ * never by a person's name.
4494
+ */
4495
+ text: string;
4496
+ };
4401
4497
  /**
4402
4498
  * @description `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
4403
4499
  * new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
@@ -4854,6 +4950,8 @@ export interface components {
4854
4950
  content: string | null;
4855
4951
  attachment: components["schemas"]["Attachment"] | null;
4856
4952
  is_deleted: boolean;
4953
+ /** @description `true` when moderation removed the answered message. Absent otherwise. */
4954
+ removed_by_moderation?: boolean;
4857
4955
  };
4858
4956
  Message: {
4859
4957
  id: components["schemas"]["Id"];
@@ -4879,6 +4977,13 @@ export interface components {
4879
4977
  created_at: components["schemas"]["Timestamp"];
4880
4978
  edited_at: components["schemas"]["Timestamp"] | null;
4881
4979
  is_deleted: boolean;
4980
+ /**
4981
+ * @description `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
4982
+ * moderation" instead of the deleted placeholder. Absent otherwise.
4983
+ */
4984
+ removed_by_moderation?: boolean;
4985
+ /** @description Why moderation removed the message; only for its sender, absent for everyone else. */
4986
+ moderation_reason?: components["schemas"]["ModerationRemovalReason"];
4882
4987
  system_event?: components["schemas"]["SystemEvent"];
4883
4988
  client_temp_id?: components["schemas"]["ClientTempId"];
4884
4989
  };
@@ -8553,6 +8658,71 @@ export interface operations {
8553
8658
  429: components["responses"]["TooManyRequests"];
8554
8659
  };
8555
8660
  };
8661
+ reportMessage: {
8662
+ parameters: {
8663
+ query?: never;
8664
+ header?: {
8665
+ /** @description Version of the client app, for logs and the per-client metric. */
8666
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
8667
+ /** @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`). */
8668
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
8669
+ };
8670
+ path: {
8671
+ chat_id: components["parameters"]["ChatId"];
8672
+ message_id: components["parameters"]["MessageId"];
8673
+ };
8674
+ cookie?: never;
8675
+ };
8676
+ requestBody: {
8677
+ content: {
8678
+ "application/json": components["schemas"]["ContentReportRequest"];
8679
+ };
8680
+ };
8681
+ responses: {
8682
+ /** @description Reported */
8683
+ 204: {
8684
+ headers: {
8685
+ [name: string]: unknown;
8686
+ };
8687
+ content?: never;
8688
+ };
8689
+ 400: components["responses"]["BadRequest"];
8690
+ 401: components["responses"]["Unauthorized"];
8691
+ 404: components["responses"]["NotFound"];
8692
+ 422: components["responses"]["ValidationFailed"];
8693
+ 426: components["responses"]["ClientOutdated"];
8694
+ 429: components["responses"]["TooManyRequests"];
8695
+ };
8696
+ };
8697
+ unreportMessage: {
8698
+ parameters: {
8699
+ query?: never;
8700
+ header?: {
8701
+ /** @description Version of the client app, for logs and the per-client metric. */
8702
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
8703
+ /** @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`). */
8704
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
8705
+ };
8706
+ path: {
8707
+ chat_id: components["parameters"]["ChatId"];
8708
+ message_id: components["parameters"]["MessageId"];
8709
+ };
8710
+ cookie?: never;
8711
+ };
8712
+ requestBody?: never;
8713
+ responses: {
8714
+ /** @description Withdrawn */
8715
+ 204: {
8716
+ headers: {
8717
+ [name: string]: unknown;
8718
+ };
8719
+ content?: never;
8720
+ };
8721
+ 400: components["responses"]["BadRequest"];
8722
+ 401: components["responses"]["Unauthorized"];
8723
+ 426: components["responses"]["ClientOutdated"];
8724
+ };
8725
+ };
8556
8726
  forwardMessages: {
8557
8727
  parameters: {
8558
8728
  query?: never;
@@ -9262,6 +9432,69 @@ export interface operations {
9262
9432
  426: components["responses"]["ClientOutdated"];
9263
9433
  };
9264
9434
  };
9435
+ reportGroup: {
9436
+ parameters: {
9437
+ query?: never;
9438
+ header?: {
9439
+ /** @description Version of the client app, for logs and the per-client metric. */
9440
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
9441
+ /** @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`). */
9442
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
9443
+ };
9444
+ path: {
9445
+ chat_id: components["parameters"]["ChatId"];
9446
+ };
9447
+ cookie?: never;
9448
+ };
9449
+ requestBody: {
9450
+ content: {
9451
+ "application/json": components["schemas"]["ContentReportRequest"];
9452
+ };
9453
+ };
9454
+ responses: {
9455
+ /** @description Reported */
9456
+ 204: {
9457
+ headers: {
9458
+ [name: string]: unknown;
9459
+ };
9460
+ content?: never;
9461
+ };
9462
+ 400: components["responses"]["BadRequest"];
9463
+ 401: components["responses"]["Unauthorized"];
9464
+ 404: components["responses"]["NotFound"];
9465
+ 422: components["responses"]["ValidationFailed"];
9466
+ 426: components["responses"]["ClientOutdated"];
9467
+ 429: components["responses"]["TooManyRequests"];
9468
+ };
9469
+ };
9470
+ unreportGroup: {
9471
+ parameters: {
9472
+ query?: never;
9473
+ header?: {
9474
+ /** @description Version of the client app, for logs and the per-client metric. */
9475
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
9476
+ /** @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`). */
9477
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
9478
+ };
9479
+ path: {
9480
+ chat_id: components["parameters"]["ChatId"];
9481
+ };
9482
+ cookie?: never;
9483
+ };
9484
+ requestBody?: never;
9485
+ responses: {
9486
+ /** @description Withdrawn */
9487
+ 204: {
9488
+ headers: {
9489
+ [name: string]: unknown;
9490
+ };
9491
+ content?: never;
9492
+ };
9493
+ 400: components["responses"]["BadRequest"];
9494
+ 401: components["responses"]["Unauthorized"];
9495
+ 426: components["responses"]["ClientOutdated"];
9496
+ };
9497
+ };
9265
9498
  getGroupRoleLog: {
9266
9499
  parameters: {
9267
9500
  query?: never;
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| `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| `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",
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.38. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.39. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -799,6 +799,16 @@ export interface Message {
799
799
  created_at: Timestamp;
800
800
  edited_at: Timestamp | null;
801
801
  is_deleted: boolean;
802
+ /**
803
+ * `true` when moderation removed the message; it is then also `is_deleted`. Clients show "Removed by
804
+ * moderation" instead of the deleted placeholder. Absent otherwise.
805
+ *
806
+ */
807
+ removed_by_moderation?: boolean;
808
+ /**
809
+ * Why moderation removed the message; only for its sender, absent for everyone else.
810
+ */
811
+ moderation_reason?: ModerationRemovalReason;
802
812
  system_event?: SystemEvent;
803
813
  client_temp_id?: ClientTempId;
804
814
  }
@@ -818,6 +828,10 @@ export interface ReplyPreview {
818
828
  content: string | null;
819
829
  attachment: Attachment | null;
820
830
  is_deleted: boolean;
831
+ /**
832
+ * `true` when moderation removed the answered message. Absent otherwise.
833
+ */
834
+ removed_by_moderation?: boolean;
821
835
  }
822
836
  export interface ForwardedFrom {
823
837
  message_id: Id;
@@ -861,6 +875,18 @@ export interface ReadReceipt {
861
875
  user_id: Id;
862
876
  read_at: Timestamp;
863
877
  }
878
+ /**
879
+ * Why moderation removed something, shown only to its author.
880
+ */
881
+ export interface ModerationRemovalReason {
882
+ code: ModerationReason;
883
+ /**
884
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
885
+ * never by a person's name.
886
+ *
887
+ */
888
+ text: string;
889
+ }
864
890
  /**
865
891
  * What a `system` message records; set on system messages only, whose `content` is then `null`. The names
866
892
  * are the display names at the time of the event. `target` fields are set for `member_added` and
@@ -909,7 +935,7 @@ export interface ServerChatListUpdateEvent {
909
935
  };
910
936
  }
911
937
  /**
912
- * A message was deleted for everyone (deleting for yourself is only sent to your other devices).
938
+ * A message was deleted for everyone (deleting for yourself is only sent to your other devices), or removed by moderation.
913
939
  */
914
940
  export interface ServerDeleteEvent {
915
941
  type: "delete";
@@ -918,8 +944,25 @@ export interface ServerDeleteEvent {
918
944
  data: {
919
945
  message_id: Id;
920
946
  scope: "me" | "everyone";
947
+ /**
948
+ * `true` when moderation removed the message (`scope` is then `everyone`). Absent otherwise.
949
+ */
950
+ removed_by_moderation?: boolean;
951
+ moderation_reason?: ModerationRemovalReason1;
921
952
  };
922
953
  }
954
+ /**
955
+ * Why moderation removed something, shown only to its author.
956
+ */
957
+ export interface ModerationRemovalReason1 {
958
+ code: ModerationReason;
959
+ /**
960
+ * A short explanation written by moderation; may be empty. Show it as written by "Messenger moderation",
961
+ * never by a person's name.
962
+ *
963
+ */
964
+ text: string;
965
+ }
923
966
  /**
924
967
  * A message was edited.
925
968
  */
@@ -1421,6 +1421,57 @@
1421
1421
  },
1422
1422
  "additionalProperties": false
1423
1423
  },
1424
+ "ContentReportReason": {
1425
+ "type": "string",
1426
+ "description": "The reasons of `ReportReason` plus `illegal`, a notice of illegal content.",
1427
+ "enum": [
1428
+ "spam",
1429
+ "scam",
1430
+ "harassment",
1431
+ "impersonation",
1432
+ "inappropriate_profile",
1433
+ "illegal",
1434
+ "other"
1435
+ ]
1436
+ },
1437
+ "ContentReportRequest": {
1438
+ "type": "object",
1439
+ "required": [
1440
+ "reason"
1441
+ ],
1442
+ "properties": {
1443
+ "reason": {
1444
+ "$ref": "#/$defs/ContentReportReason"
1445
+ },
1446
+ "note": {
1447
+ "type": [
1448
+ "string",
1449
+ "null"
1450
+ ],
1451
+ "maxLength": 1000,
1452
+ "description": "Details for moderation, never shown to the sender or the group. Required for `illegal`: why the content is\nillegal, for example which law it breaks.\n"
1453
+ }
1454
+ },
1455
+ "additionalProperties": false
1456
+ },
1457
+ "ModerationRemovalReason": {
1458
+ "type": "object",
1459
+ "description": "Why moderation removed something, shown only to its author.",
1460
+ "required": [
1461
+ "code",
1462
+ "text"
1463
+ ],
1464
+ "properties": {
1465
+ "code": {
1466
+ "$ref": "#/$defs/ModerationReason"
1467
+ },
1468
+ "text": {
1469
+ "type": "string",
1470
+ "maxLength": 1000,
1471
+ "description": "A short explanation written by moderation; may be empty. Show it as written by \"Messenger moderation\",\nnever by a person's name.\n"
1472
+ }
1473
+ }
1474
+ },
1424
1475
  "AccountStatusLevel": {
1425
1476
  "type": "string",
1426
1477
  "description": "`good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5\nnew direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker\nand emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).\nUnknown values must be treated like `restricted`.\n",
@@ -2927,6 +2978,10 @@
2927
2978
  },
2928
2979
  "is_deleted": {
2929
2980
  "type": "boolean"
2981
+ },
2982
+ "removed_by_moderation": {
2983
+ "type": "boolean",
2984
+ "description": "`true` when moderation removed the answered message. Absent otherwise."
2930
2985
  }
2931
2986
  }
2932
2987
  },
@@ -3050,6 +3105,18 @@
3050
3105
  "is_deleted": {
3051
3106
  "type": "boolean"
3052
3107
  },
3108
+ "removed_by_moderation": {
3109
+ "type": "boolean",
3110
+ "description": "`true` when moderation removed the message; it is then also `is_deleted`. Clients show \"Removed by\nmoderation\" instead of the deleted placeholder. Absent otherwise.\n"
3111
+ },
3112
+ "moderation_reason": {
3113
+ "allOf": [
3114
+ {
3115
+ "$ref": "#/$defs/ModerationRemovalReason"
3116
+ }
3117
+ ],
3118
+ "description": "Why moderation removed the message; only for its sender, absent for everyone else."
3119
+ },
3053
3120
  "system_event": {
3054
3121
  "$ref": "#/$defs/SystemEvent"
3055
3122
  },
@@ -5838,7 +5905,7 @@
5838
5905
  },
5839
5906
  "ServerDeleteEvent": {
5840
5907
  "title": "ServerDeleteEvent",
5841
- "description": "A message was deleted for everyone (deleting for yourself is only sent to your other devices).",
5908
+ "description": "A message was deleted for everyone (deleting for yourself is only sent to your other devices), or removed by moderation.",
5842
5909
  "type": "object",
5843
5910
  "properties": {
5844
5911
  "type": {
@@ -5862,6 +5929,14 @@
5862
5929
  "me",
5863
5930
  "everyone"
5864
5931
  ]
5932
+ },
5933
+ "removed_by_moderation": {
5934
+ "type": "boolean",
5935
+ "description": "`true` when moderation removed the message (`scope` is then `everyone`). Absent otherwise."
5936
+ },
5937
+ "moderation_reason": {
5938
+ "$ref": "#/$defs/ModerationRemovalReason",
5939
+ "description": "Why moderation removed the message; only in the sender's copy of the event."
5865
5940
  }
5866
5941
  },
5867
5942
  "required": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.38.next.135",
3
+ "version": "2.1.0-alpha.39",
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": {