@myronsi/messenger-api 2.1.0-alpha.37.next.132 → 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 +16 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +175 -2
- package/dist/schema.d.ts +309 -1
- package/dist/ws-docs.json +4 -2
- package/dist/ws-events.d.ts +55 -2
- package/dist/ws-events.schema.json +108 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
|
|
14
|
+
## 2.1.0-alpha.38
|
|
15
|
+
|
|
16
|
+
- Review by a person: `POST /me/account-status/review` (`AccountReviewRequest`: `text`, 1 to 500 characters) stores a
|
|
17
|
+
request for the moderation team while the status is not `good`; one open request at a time (`409`), at most 3 in
|
|
18
|
+
30 days (`429`). `AccountStatus` gains `review_requested_at` and `can_request_review`, also in the
|
|
19
|
+
WebSocket event `account_status`.
|
|
20
|
+
|
|
5
21
|
## 2.1.0-alpha.37
|
|
6
22
|
|
|
7
23
|
- `AccountStatus` gains the optional `decided_by` (`AccountStatusDecidedBy`: `automatic`, `staff`), `reason_code`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
2
|
-
export declare const API_VERSION: "2.1.0-alpha.
|
|
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.
|
|
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.
|
|
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
|
|
@@ -1216,6 +1216,37 @@ paths:
|
|
|
1216
1216
|
description: Marked as read
|
|
1217
1217
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1218
1218
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
1219
|
+
/me/account-status/review:
|
|
1220
|
+
parameters:
|
|
1221
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1222
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1223
|
+
post:
|
|
1224
|
+
tags: [me]
|
|
1225
|
+
operationId: requestAccountReview
|
|
1226
|
+
summary: Ask for a review of the account status by a person
|
|
1227
|
+
description: |
|
|
1228
|
+
Stores the request with the user's text and the current status for the moderation team, who review the
|
|
1229
|
+
account and decide; the decision arrives as an account status with `decided_by: staff` and the reason. Allowed while the
|
|
1230
|
+
status is not `good` and no request is open (`can_request_review`), otherwise `409`; at most 3 requests in
|
|
1231
|
+
30 days, otherwise `429`. A request closes when a person decides or when the status returns to `good`. The
|
|
1232
|
+
answer and the WebSocket event `account_status` carry `review_requested_at`.
|
|
1233
|
+
requestBody:
|
|
1234
|
+
required: true
|
|
1235
|
+
content:
|
|
1236
|
+
application/json:
|
|
1237
|
+
schema: { $ref: "#/components/schemas/AccountReviewRequest" }
|
|
1238
|
+
responses:
|
|
1239
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1240
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1241
|
+
"200":
|
|
1242
|
+
description: The account status with the open request
|
|
1243
|
+
content:
|
|
1244
|
+
application/json:
|
|
1245
|
+
schema: { $ref: "#/components/schemas/AccountStatus" }
|
|
1246
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1247
|
+
"409": { $ref: "#/components/responses/Conflict" }
|
|
1248
|
+
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
1249
|
+
"429": { $ref: "#/components/responses/TooManyRequests" }
|
|
1219
1250
|
/users/{user_id}/avatar:
|
|
1220
1251
|
parameters:
|
|
1221
1252
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -2163,6 +2194,50 @@ paths:
|
|
|
2163
2194
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
2164
2195
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
2165
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" }
|
|
2166
2241
|
/chats/{chat_id}/messages/forward:
|
|
2167
2242
|
parameters:
|
|
2168
2243
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -2656,6 +2731,46 @@ paths:
|
|
|
2656
2731
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2657
2732
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
2658
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" }
|
|
2659
2774
|
/groups/{chat_id}/role-log:
|
|
2660
2775
|
parameters:
|
|
2661
2776
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -6179,6 +6294,34 @@ components:
|
|
|
6179
6294
|
default: true
|
|
6180
6295
|
description: Also block the user.
|
|
6181
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.
|
|
6182
6325
|
AccountStatusLevel:
|
|
6183
6326
|
type: string
|
|
6184
6327
|
description: |
|
|
@@ -6193,7 +6336,7 @@ components:
|
|
|
6193
6336
|
enum: [start_direct, invite_to_group, call, create_group, upload, forward, edit_profile, publish_pack, search, send, manage_group]
|
|
6194
6337
|
AccountStatus:
|
|
6195
6338
|
type: object
|
|
6196
|
-
required: [status, since, restrictions, can_appeal, probation_until]
|
|
6339
|
+
required: [status, since, restrictions, can_appeal, probation_until, review_requested_at, can_request_review]
|
|
6197
6340
|
properties:
|
|
6198
6341
|
status: { $ref: "#/components/schemas/AccountStatusLevel" }
|
|
6199
6342
|
since:
|
|
@@ -6223,6 +6366,25 @@ components:
|
|
|
6223
6366
|
description: |
|
|
6224
6367
|
The explanation written for the user by the moderation team; `null` for automatic statuses. Show it as
|
|
6225
6368
|
written by "Messenger moderation", never by a person's name.
|
|
6369
|
+
review_requested_at:
|
|
6370
|
+
description: |
|
|
6371
|
+
When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when
|
|
6372
|
+
none is open.
|
|
6373
|
+
oneOf:
|
|
6374
|
+
- $ref: "#/components/schemas/Timestamp"
|
|
6375
|
+
- type: "null"
|
|
6376
|
+
can_request_review:
|
|
6377
|
+
type: boolean
|
|
6378
|
+
description: Whether `POST /me/account-status/review` is allowed now.
|
|
6379
|
+
AccountReviewRequest:
|
|
6380
|
+
type: object
|
|
6381
|
+
required: [text]
|
|
6382
|
+
properties:
|
|
6383
|
+
text:
|
|
6384
|
+
type: string
|
|
6385
|
+
minLength: 1
|
|
6386
|
+
maxLength: 500
|
|
6387
|
+
description: What the user wants the reviewer to know. Trimmed; must not be empty.
|
|
6226
6388
|
AccountStatusDecidedBy:
|
|
6227
6389
|
type: string
|
|
6228
6390
|
description: |
|
|
@@ -6869,6 +7031,9 @@ components:
|
|
|
6869
7031
|
- $ref: "#/components/schemas/Attachment"
|
|
6870
7032
|
- type: "null"
|
|
6871
7033
|
is_deleted: { type: boolean }
|
|
7034
|
+
removed_by_moderation:
|
|
7035
|
+
type: boolean
|
|
7036
|
+
description: "`true` when moderation removed the answered message. Absent otherwise."
|
|
6872
7037
|
Message:
|
|
6873
7038
|
type: object
|
|
6874
7039
|
required:
|
|
@@ -6935,6 +7100,14 @@ components:
|
|
|
6935
7100
|
- $ref: "#/components/schemas/Timestamp"
|
|
6936
7101
|
- type: "null"
|
|
6937
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.
|
|
6938
7111
|
system_event:
|
|
6939
7112
|
$ref: "#/components/schemas/SystemEvent"
|
|
6940
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.
|
|
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: {
|
|
@@ -1087,6 +1087,35 @@ export interface paths {
|
|
|
1087
1087
|
patch?: never;
|
|
1088
1088
|
trace?: never;
|
|
1089
1089
|
};
|
|
1090
|
+
"/me/account-status/review": {
|
|
1091
|
+
parameters: {
|
|
1092
|
+
query?: never;
|
|
1093
|
+
header?: {
|
|
1094
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
1095
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
1096
|
+
/** @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`). */
|
|
1097
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
1098
|
+
};
|
|
1099
|
+
path?: never;
|
|
1100
|
+
cookie?: never;
|
|
1101
|
+
};
|
|
1102
|
+
get?: never;
|
|
1103
|
+
put?: never;
|
|
1104
|
+
/**
|
|
1105
|
+
* Ask for a review of the account status by a person
|
|
1106
|
+
* @description Stores the request with the user's text and the current status for the moderation team, who review the
|
|
1107
|
+
* account and decide; the decision arrives as an account status with `decided_by: staff` and the reason. Allowed while the
|
|
1108
|
+
* status is not `good` and no request is open (`can_request_review`), otherwise `409`; at most 3 requests in
|
|
1109
|
+
* 30 days, otherwise `429`. A request closes when a person decides or when the status returns to `good`. The
|
|
1110
|
+
* answer and the WebSocket event `account_status` carry `review_requested_at`.
|
|
1111
|
+
*/
|
|
1112
|
+
post: operations["requestAccountReview"];
|
|
1113
|
+
delete?: never;
|
|
1114
|
+
options?: never;
|
|
1115
|
+
head?: never;
|
|
1116
|
+
patch?: never;
|
|
1117
|
+
trace?: never;
|
|
1118
|
+
};
|
|
1090
1119
|
"/users/{user_id}/avatar": {
|
|
1091
1120
|
parameters: {
|
|
1092
1121
|
query?: never;
|
|
@@ -1850,6 +1879,45 @@ export interface paths {
|
|
|
1850
1879
|
patch?: never;
|
|
1851
1880
|
trace?: never;
|
|
1852
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
|
+
};
|
|
1853
1921
|
"/chats/{chat_id}/messages/forward": {
|
|
1854
1922
|
parameters: {
|
|
1855
1923
|
query?: never;
|
|
@@ -2228,6 +2296,41 @@ export interface paths {
|
|
|
2228
2296
|
patch?: never;
|
|
2229
2297
|
trace?: never;
|
|
2230
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
|
+
};
|
|
2231
2334
|
"/groups/{chat_id}/role-log": {
|
|
2232
2335
|
parameters: {
|
|
2233
2336
|
query?: never;
|
|
@@ -4369,6 +4472,28 @@ export interface components {
|
|
|
4369
4472
|
*/
|
|
4370
4473
|
block: boolean;
|
|
4371
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
|
+
};
|
|
4372
4497
|
/**
|
|
4373
4498
|
* @description `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
|
|
4374
4499
|
* new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
|
|
@@ -4398,6 +4523,17 @@ export interface components {
|
|
|
4398
4523
|
* written by "Messenger moderation", never by a person's name.
|
|
4399
4524
|
*/
|
|
4400
4525
|
reason_text?: string | null;
|
|
4526
|
+
/**
|
|
4527
|
+
* @description When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when
|
|
4528
|
+
* none is open.
|
|
4529
|
+
*/
|
|
4530
|
+
review_requested_at: components["schemas"]["Timestamp"] | null;
|
|
4531
|
+
/** @description Whether `POST /me/account-status/review` is allowed now. */
|
|
4532
|
+
can_request_review: boolean;
|
|
4533
|
+
};
|
|
4534
|
+
AccountReviewRequest: {
|
|
4535
|
+
/** @description What the user wants the reviewer to know. Trimmed; must not be empty. */
|
|
4536
|
+
text: string;
|
|
4401
4537
|
};
|
|
4402
4538
|
/**
|
|
4403
4539
|
* @description Who set the current status: `automatic` (reports, decay, appeal) or `staff` (reviewed by a person on the
|
|
@@ -4814,6 +4950,8 @@ export interface components {
|
|
|
4814
4950
|
content: string | null;
|
|
4815
4951
|
attachment: components["schemas"]["Attachment"] | null;
|
|
4816
4952
|
is_deleted: boolean;
|
|
4953
|
+
/** @description `true` when moderation removed the answered message. Absent otherwise. */
|
|
4954
|
+
removed_by_moderation?: boolean;
|
|
4817
4955
|
};
|
|
4818
4956
|
Message: {
|
|
4819
4957
|
id: components["schemas"]["Id"];
|
|
@@ -4839,6 +4977,13 @@ export interface components {
|
|
|
4839
4977
|
created_at: components["schemas"]["Timestamp"];
|
|
4840
4978
|
edited_at: components["schemas"]["Timestamp"] | null;
|
|
4841
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"];
|
|
4842
4987
|
system_event?: components["schemas"]["SystemEvent"];
|
|
4843
4988
|
client_temp_id?: components["schemas"]["ClientTempId"];
|
|
4844
4989
|
};
|
|
@@ -7211,6 +7356,41 @@ export interface operations {
|
|
|
7211
7356
|
426: components["responses"]["ClientOutdated"];
|
|
7212
7357
|
};
|
|
7213
7358
|
};
|
|
7359
|
+
requestAccountReview: {
|
|
7360
|
+
parameters: {
|
|
7361
|
+
query?: never;
|
|
7362
|
+
header?: {
|
|
7363
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
7364
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
7365
|
+
/** @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`). */
|
|
7366
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
7367
|
+
};
|
|
7368
|
+
path?: never;
|
|
7369
|
+
cookie?: never;
|
|
7370
|
+
};
|
|
7371
|
+
requestBody: {
|
|
7372
|
+
content: {
|
|
7373
|
+
"application/json": components["schemas"]["AccountReviewRequest"];
|
|
7374
|
+
};
|
|
7375
|
+
};
|
|
7376
|
+
responses: {
|
|
7377
|
+
/** @description The account status with the open request */
|
|
7378
|
+
200: {
|
|
7379
|
+
headers: {
|
|
7380
|
+
[name: string]: unknown;
|
|
7381
|
+
};
|
|
7382
|
+
content: {
|
|
7383
|
+
"application/json": components["schemas"]["AccountStatus"];
|
|
7384
|
+
};
|
|
7385
|
+
};
|
|
7386
|
+
400: components["responses"]["BadRequest"];
|
|
7387
|
+
401: components["responses"]["Unauthorized"];
|
|
7388
|
+
409: components["responses"]["Conflict"];
|
|
7389
|
+
422: components["responses"]["ValidationFailed"];
|
|
7390
|
+
426: components["responses"]["ClientOutdated"];
|
|
7391
|
+
429: components["responses"]["TooManyRequests"];
|
|
7392
|
+
};
|
|
7393
|
+
};
|
|
7214
7394
|
getUserAvatar: {
|
|
7215
7395
|
parameters: {
|
|
7216
7396
|
query?: {
|
|
@@ -8478,6 +8658,71 @@ export interface operations {
|
|
|
8478
8658
|
429: components["responses"]["TooManyRequests"];
|
|
8479
8659
|
};
|
|
8480
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
|
+
};
|
|
8481
8726
|
forwardMessages: {
|
|
8482
8727
|
parameters: {
|
|
8483
8728
|
query?: never;
|
|
@@ -9187,6 +9432,69 @@ export interface operations {
|
|
|
9187
9432
|
426: components["responses"]["ClientOutdated"];
|
|
9188
9433
|
};
|
|
9189
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
|
+
};
|
|
9190
9498
|
getGroupRoleLog: {
|
|
9191
9499
|
parameters: {
|
|
9192
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",
|
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
"probation_until": null,
|
|
93
93
|
"decided_by": "staff",
|
|
94
94
|
"reason_code": "spam",
|
|
95
|
-
"reason_text": "Your account sent the same advertising link to many people who did not know you."
|
|
95
|
+
"reason_text": "Your account sent the same advertising link to many people who did not know you.",
|
|
96
|
+
"review_requested_at": null,
|
|
97
|
+
"can_request_review": true
|
|
96
98
|
}
|
|
97
99
|
},
|
|
98
100
|
"server/ack.json": {
|
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.39. Do not edit. */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Any WebSocket event, in either direction.
|
|
@@ -336,6 +336,16 @@ export interface AccountStatus {
|
|
|
336
336
|
*
|
|
337
337
|
*/
|
|
338
338
|
reason_text?: string | null;
|
|
339
|
+
/**
|
|
340
|
+
* When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when
|
|
341
|
+
* none is open.
|
|
342
|
+
*
|
|
343
|
+
*/
|
|
344
|
+
review_requested_at: Timestamp | null;
|
|
345
|
+
/**
|
|
346
|
+
* Whether `POST /me/account-status/review` is allowed now.
|
|
347
|
+
*/
|
|
348
|
+
can_request_review: boolean;
|
|
339
349
|
}
|
|
340
350
|
/**
|
|
341
351
|
* The server accepted the client event with this `client_temp_id`.
|
|
@@ -789,6 +799,16 @@ export interface Message {
|
|
|
789
799
|
created_at: Timestamp;
|
|
790
800
|
edited_at: Timestamp | null;
|
|
791
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;
|
|
792
812
|
system_event?: SystemEvent;
|
|
793
813
|
client_temp_id?: ClientTempId;
|
|
794
814
|
}
|
|
@@ -808,6 +828,10 @@ export interface ReplyPreview {
|
|
|
808
828
|
content: string | null;
|
|
809
829
|
attachment: Attachment | null;
|
|
810
830
|
is_deleted: boolean;
|
|
831
|
+
/**
|
|
832
|
+
* `true` when moderation removed the answered message. Absent otherwise.
|
|
833
|
+
*/
|
|
834
|
+
removed_by_moderation?: boolean;
|
|
811
835
|
}
|
|
812
836
|
export interface ForwardedFrom {
|
|
813
837
|
message_id: Id;
|
|
@@ -851,6 +875,18 @@ export interface ReadReceipt {
|
|
|
851
875
|
user_id: Id;
|
|
852
876
|
read_at: Timestamp;
|
|
853
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
|
+
}
|
|
854
890
|
/**
|
|
855
891
|
* What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
856
892
|
* are the display names at the time of the event. `target` fields are set for `member_added` and
|
|
@@ -899,7 +935,7 @@ export interface ServerChatListUpdateEvent {
|
|
|
899
935
|
};
|
|
900
936
|
}
|
|
901
937
|
/**
|
|
902
|
-
* 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.
|
|
903
939
|
*/
|
|
904
940
|
export interface ServerDeleteEvent {
|
|
905
941
|
type: "delete";
|
|
@@ -908,8 +944,25 @@ export interface ServerDeleteEvent {
|
|
|
908
944
|
data: {
|
|
909
945
|
message_id: Id;
|
|
910
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;
|
|
911
952
|
};
|
|
912
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
|
+
}
|
|
913
966
|
/**
|
|
914
967
|
* A message was edited.
|
|
915
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",
|
|
@@ -1456,7 +1507,9 @@
|
|
|
1456
1507
|
"since",
|
|
1457
1508
|
"restrictions",
|
|
1458
1509
|
"can_appeal",
|
|
1459
|
-
"probation_until"
|
|
1510
|
+
"probation_until",
|
|
1511
|
+
"review_requested_at",
|
|
1512
|
+
"can_request_review"
|
|
1460
1513
|
],
|
|
1461
1514
|
"properties": {
|
|
1462
1515
|
"status": {
|
|
@@ -1514,6 +1567,35 @@
|
|
|
1514
1567
|
],
|
|
1515
1568
|
"maxLength": 1000,
|
|
1516
1569
|
"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"
|
|
1570
|
+
},
|
|
1571
|
+
"review_requested_at": {
|
|
1572
|
+
"description": "When the open request for a review by a person (`POST /me/account-status/review`) was made; `null` when\nnone is open.\n",
|
|
1573
|
+
"oneOf": [
|
|
1574
|
+
{
|
|
1575
|
+
"$ref": "#/$defs/Timestamp"
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
"type": "null"
|
|
1579
|
+
}
|
|
1580
|
+
]
|
|
1581
|
+
},
|
|
1582
|
+
"can_request_review": {
|
|
1583
|
+
"type": "boolean",
|
|
1584
|
+
"description": "Whether `POST /me/account-status/review` is allowed now."
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
"AccountReviewRequest": {
|
|
1589
|
+
"type": "object",
|
|
1590
|
+
"required": [
|
|
1591
|
+
"text"
|
|
1592
|
+
],
|
|
1593
|
+
"properties": {
|
|
1594
|
+
"text": {
|
|
1595
|
+
"type": "string",
|
|
1596
|
+
"minLength": 1,
|
|
1597
|
+
"maxLength": 500,
|
|
1598
|
+
"description": "What the user wants the reviewer to know. Trimmed; must not be empty."
|
|
1517
1599
|
}
|
|
1518
1600
|
}
|
|
1519
1601
|
},
|
|
@@ -2896,6 +2978,10 @@
|
|
|
2896
2978
|
},
|
|
2897
2979
|
"is_deleted": {
|
|
2898
2980
|
"type": "boolean"
|
|
2981
|
+
},
|
|
2982
|
+
"removed_by_moderation": {
|
|
2983
|
+
"type": "boolean",
|
|
2984
|
+
"description": "`true` when moderation removed the answered message. Absent otherwise."
|
|
2899
2985
|
}
|
|
2900
2986
|
}
|
|
2901
2987
|
},
|
|
@@ -3019,6 +3105,18 @@
|
|
|
3019
3105
|
"is_deleted": {
|
|
3020
3106
|
"type": "boolean"
|
|
3021
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
|
+
},
|
|
3022
3120
|
"system_event": {
|
|
3023
3121
|
"$ref": "#/$defs/SystemEvent"
|
|
3024
3122
|
},
|
|
@@ -5807,7 +5905,7 @@
|
|
|
5807
5905
|
},
|
|
5808
5906
|
"ServerDeleteEvent": {
|
|
5809
5907
|
"title": "ServerDeleteEvent",
|
|
5810
|
-
"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.",
|
|
5811
5909
|
"type": "object",
|
|
5812
5910
|
"properties": {
|
|
5813
5911
|
"type": {
|
|
@@ -5831,6 +5929,14 @@
|
|
|
5831
5929
|
"me",
|
|
5832
5930
|
"everyone"
|
|
5833
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."
|
|
5834
5940
|
}
|
|
5835
5941
|
},
|
|
5836
5942
|
"required": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myronsi/messenger-api",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
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": {
|