@myronsi/messenger-api 2.1.0-alpha.35.next.125 → 2.1.0-alpha.36.next.127
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 +11 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +151 -2
- package/dist/schema.d.ts +261 -3
- package/dist/ws-docs.json +17 -1
- package/dist/ws-events.d.ts +70 -1
- package/dist/ws-events.schema.json +165 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.36
|
|
6
|
+
|
|
7
|
+
- User reports: `POST /users/{user_id}/report` (`ReportUserRequest`: `ReportReason`, optional `note`, `block`
|
|
8
|
+
default `true`) and `DELETE /users/{user_id}/report`.
|
|
9
|
+
- Automatic account status: `GET /me/account-status` and `POST /me/account-status/appeal` return `AccountStatus`
|
|
10
|
+
(`AccountStatusLevel`, `AccountRestriction`, including `manage_group` for group changes of a suspended
|
|
11
|
+
account); the WebSocket event `account_status` carries it to the user's own sessions.
|
|
12
|
+
- `ErrorCode` gains `account_restricted` (`403`); `Problem.restriction` and the WebSocket `error` event's
|
|
13
|
+
`data.restriction` name the blocked action.
|
|
14
|
+
- `User.account_label` (`AccountLabel`: `restricted`) marks suspended accounts.
|
|
15
|
+
|
|
5
16
|
## 2.1.0-alpha.35
|
|
6
17
|
|
|
7
18
|
- `PrivacySettings` gains the required `voice_video_messages` (`VoiceVideoPolicy`: `everyone`, `contacts`) and
|
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.36. Do not edit. */
|
|
2
|
+
export declare const API_VERSION: "2.1.0-alpha.36";
|
|
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.36";
|
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.36
|
|
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
|
|
@@ -360,6 +360,7 @@ paths:
|
|
|
360
360
|
schema: { $ref: "#/components/schemas/Me" }
|
|
361
361
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
362
362
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
363
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
363
364
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
364
365
|
delete:
|
|
365
366
|
tags: [me]
|
|
@@ -401,6 +402,7 @@ paths:
|
|
|
401
402
|
schema: { $ref: "#/components/schemas/Me" }
|
|
402
403
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
403
404
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
405
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
404
406
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
405
407
|
/me/avatars/{avatar_id}:
|
|
406
408
|
parameters:
|
|
@@ -452,6 +454,7 @@ paths:
|
|
|
452
454
|
schema: { $ref: "#/components/schemas/Me" }
|
|
453
455
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
454
456
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
457
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
455
458
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
456
459
|
delete:
|
|
457
460
|
tags: [me]
|
|
@@ -487,6 +490,7 @@ paths:
|
|
|
487
490
|
schema: { $ref: "#/components/schemas/Me" }
|
|
488
491
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
489
492
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
493
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
490
494
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
491
495
|
delete:
|
|
492
496
|
tags: [me]
|
|
@@ -1092,6 +1096,87 @@ paths:
|
|
|
1092
1096
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1093
1097
|
"404": { $ref: "#/components/responses/NotFound" }
|
|
1094
1098
|
"429": { $ref: "#/components/responses/TooManyRequests" }
|
|
1099
|
+
/users/{user_id}/report:
|
|
1100
|
+
parameters:
|
|
1101
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1102
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1103
|
+
- $ref: "#/components/parameters/UserId"
|
|
1104
|
+
post:
|
|
1105
|
+
tags: [users]
|
|
1106
|
+
operationId: reportUser
|
|
1107
|
+
summary: Report a user
|
|
1108
|
+
description: |
|
|
1109
|
+
One active report per reporter and user; reporting again changes the reason and the note. The reported user
|
|
1110
|
+
never learns who reported them. `block` (default `true`) also blocks the user, like
|
|
1111
|
+
`PUT /me/blocked-users/{user_id}`. Reporting yourself is `422`. At most 20 reports a day (`429`).
|
|
1112
|
+
Reports drive the reported user's account status automatically (`GET /me/account-status`).
|
|
1113
|
+
requestBody:
|
|
1114
|
+
required: true
|
|
1115
|
+
content:
|
|
1116
|
+
application/json:
|
|
1117
|
+
schema: { $ref: "#/components/schemas/ReportUserRequest" }
|
|
1118
|
+
responses:
|
|
1119
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1120
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1121
|
+
"204":
|
|
1122
|
+
description: Reported
|
|
1123
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1124
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
1125
|
+
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
1126
|
+
"429": { $ref: "#/components/responses/TooManyRequests" }
|
|
1127
|
+
delete:
|
|
1128
|
+
tags: [users]
|
|
1129
|
+
operationId: unreportUser
|
|
1130
|
+
summary: Withdraw a report
|
|
1131
|
+
description: Withdraws the current user's report on the user. Withdrawing a report that does not exist is fine.
|
|
1132
|
+
responses:
|
|
1133
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1134
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1135
|
+
"204":
|
|
1136
|
+
description: Withdrawn
|
|
1137
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1138
|
+
/me/account-status:
|
|
1139
|
+
parameters:
|
|
1140
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1141
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1142
|
+
get:
|
|
1143
|
+
tags: [me]
|
|
1144
|
+
operationId: getAccountStatus
|
|
1145
|
+
summary: The current user's account status
|
|
1146
|
+
description: |
|
|
1147
|
+
The status follows the reports on the account automatically (`docs/moderation.md`). `restrictions` lists
|
|
1148
|
+
what the status blocks. The WebSocket event `account_status` carries the same object when it changes.
|
|
1149
|
+
responses:
|
|
1150
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1151
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1152
|
+
"200":
|
|
1153
|
+
description: The account status
|
|
1154
|
+
content:
|
|
1155
|
+
application/json:
|
|
1156
|
+
schema: { $ref: "#/components/schemas/AccountStatus" }
|
|
1157
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1158
|
+
/me/account-status/appeal:
|
|
1159
|
+
parameters:
|
|
1160
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
1161
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
1162
|
+
post:
|
|
1163
|
+
tags: [me]
|
|
1164
|
+
operationId: appealAccountStatus
|
|
1165
|
+
summary: Appeal the account status
|
|
1166
|
+
description: |
|
|
1167
|
+
Automatic appeal (probation): the status drops one level for 14 days. Without a new weighted report in that
|
|
1168
|
+
time the lower level stays; a new one restores the status and blocks appeals for 90 days. Allowed once per
|
|
1169
|
+
30 days and only when `can_appeal` is `true`, otherwise `409`.
|
|
1170
|
+
responses:
|
|
1171
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
1172
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1173
|
+
"200":
|
|
1174
|
+
description: The new account status
|
|
1175
|
+
content:
|
|
1176
|
+
application/json:
|
|
1177
|
+
schema: { $ref: "#/components/schemas/AccountStatus" }
|
|
1178
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1179
|
+
"409": { $ref: "#/components/responses/Conflict" }
|
|
1095
1180
|
/users/{user_id}/avatar:
|
|
1096
1181
|
parameters:
|
|
1097
1182
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -1237,6 +1322,7 @@ paths:
|
|
|
1237
1322
|
schema: { $ref: "#/components/schemas/Attachment" }
|
|
1238
1323
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1239
1324
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1325
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
1240
1326
|
"413": { $ref: "#/components/responses/PayloadTooLarge" }
|
|
1241
1327
|
"415": { $ref: "#/components/responses/UnsupportedMediaType" }
|
|
1242
1328
|
"429": { $ref: "#/components/responses/TooManyRequests" }
|
|
@@ -1362,6 +1448,7 @@ paths:
|
|
|
1362
1448
|
schema: { $ref: "#/components/schemas/UploadSession" }
|
|
1363
1449
|
"400": { $ref: "#/components/responses/BadRequest" }
|
|
1364
1450
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
1451
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
1365
1452
|
"413": { $ref: "#/components/responses/PayloadTooLarge" }
|
|
1366
1453
|
"429": { $ref: "#/components/responses/TooManyRequests" }
|
|
1367
1454
|
/upload-sessions/{upload_id}:
|
|
@@ -2599,6 +2686,7 @@ paths:
|
|
|
2599
2686
|
application/json:
|
|
2600
2687
|
schema: { $ref: "#/components/schemas/StickerPack" }
|
|
2601
2688
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2689
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
2602
2690
|
"409": { $ref: "#/components/responses/Conflict" }
|
|
2603
2691
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
2604
2692
|
/stickers/packs/{pack_id}:
|
|
@@ -2886,6 +2974,7 @@ paths:
|
|
|
2886
2974
|
application/json:
|
|
2887
2975
|
schema: { $ref: "#/components/schemas/EmojiPack" }
|
|
2888
2976
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2977
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
2889
2978
|
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
2890
2979
|
/emoji/packs/{pack_id}:
|
|
2891
2980
|
parameters:
|
|
@@ -5278,7 +5367,7 @@ components:
|
|
|
5278
5367
|
application/problem+json:
|
|
5279
5368
|
schema: { $ref: "#/components/schemas/Problem" }
|
|
5280
5369
|
Forbidden:
|
|
5281
|
-
description: Authenticated but not allowed
|
|
5370
|
+
description: Authenticated but not allowed. `account_restricted` (with `restriction`) when the account status blocks the action.
|
|
5282
5371
|
content:
|
|
5283
5372
|
application/problem+json:
|
|
5284
5373
|
schema: { $ref: "#/components/schemas/Problem" }
|
|
@@ -5495,6 +5584,7 @@ components:
|
|
|
5495
5584
|
- already_in_call
|
|
5496
5585
|
- stale_epoch
|
|
5497
5586
|
- limit_reached
|
|
5587
|
+
- account_restricted
|
|
5498
5588
|
- internal_error
|
|
5499
5589
|
Problem:
|
|
5500
5590
|
type: object
|
|
@@ -5527,6 +5617,9 @@ components:
|
|
|
5527
5617
|
api_version:
|
|
5528
5618
|
type: string
|
|
5529
5619
|
description: Present when `code` is `client_outdated`.
|
|
5620
|
+
restriction:
|
|
5621
|
+
allOf: [{ $ref: "#/components/schemas/AccountRestriction" }]
|
|
5622
|
+
description: Present when `code` is `account_restricted` (`403`); names what the account status blocks.
|
|
5530
5623
|
additionalProperties: true
|
|
5531
5624
|
Meta:
|
|
5532
5625
|
type: object
|
|
@@ -6017,6 +6110,62 @@ components:
|
|
|
6017
6110
|
description: |
|
|
6018
6111
|
Only on `Chat.peer` of a direct chat: whether the requesting user may send this user voice messages and
|
|
6019
6112
|
videos (their `voice_video_messages` setting and exceptions). Absent everywhere else.
|
|
6113
|
+
account_label:
|
|
6114
|
+
allOf: [{ $ref: "#/components/schemas/AccountLabel" }]
|
|
6115
|
+
description: |
|
|
6116
|
+
`restricted` when the account is suspended by its automatic account status; clients show "Restricted
|
|
6117
|
+
account". Absent otherwise.
|
|
6118
|
+
AccountLabel:
|
|
6119
|
+
type: string
|
|
6120
|
+
enum: [restricted]
|
|
6121
|
+
ReportReason:
|
|
6122
|
+
type: string
|
|
6123
|
+
enum: [spam, scam, harassment, impersonation, inappropriate_profile, other]
|
|
6124
|
+
ReportUserRequest:
|
|
6125
|
+
type: object
|
|
6126
|
+
required: [reason]
|
|
6127
|
+
properties:
|
|
6128
|
+
reason: { $ref: "#/components/schemas/ReportReason" }
|
|
6129
|
+
note:
|
|
6130
|
+
type: [string, "null"]
|
|
6131
|
+
maxLength: 500
|
|
6132
|
+
description: Optional details for the report. Never shown to the reported user.
|
|
6133
|
+
block:
|
|
6134
|
+
type: boolean
|
|
6135
|
+
default: true
|
|
6136
|
+
description: Also block the user.
|
|
6137
|
+
additionalProperties: false
|
|
6138
|
+
AccountStatusLevel:
|
|
6139
|
+
type: string
|
|
6140
|
+
description: |
|
|
6141
|
+
`good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
|
|
6142
|
+
new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
|
|
6143
|
+
and emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).
|
|
6144
|
+
Unknown values must be treated like `restricted`.
|
|
6145
|
+
enum: [good, warned, limited, restricted, suspended]
|
|
6146
|
+
AccountRestriction:
|
|
6147
|
+
type: string
|
|
6148
|
+
description: An action the account status blocks. Unknown values must be shown as a generic restriction.
|
|
6149
|
+
enum: [start_direct, invite_to_group, call, create_group, upload, forward, edit_profile, publish_pack, search, send, manage_group]
|
|
6150
|
+
AccountStatus:
|
|
6151
|
+
type: object
|
|
6152
|
+
required: [status, since, restrictions, can_appeal, probation_until]
|
|
6153
|
+
properties:
|
|
6154
|
+
status: { $ref: "#/components/schemas/AccountStatusLevel" }
|
|
6155
|
+
since:
|
|
6156
|
+
description: When the account reached this status; `null` when it never changed.
|
|
6157
|
+
oneOf:
|
|
6158
|
+
- $ref: "#/components/schemas/Timestamp"
|
|
6159
|
+
- type: "null"
|
|
6160
|
+
restrictions:
|
|
6161
|
+
type: array
|
|
6162
|
+
items: { $ref: "#/components/schemas/AccountRestriction" }
|
|
6163
|
+
can_appeal: { type: boolean }
|
|
6164
|
+
probation_until:
|
|
6165
|
+
description: End of the running probation after an appeal; `null` when none runs.
|
|
6166
|
+
oneOf:
|
|
6167
|
+
- $ref: "#/components/schemas/Timestamp"
|
|
6168
|
+
- type: "null"
|
|
6020
6169
|
Me:
|
|
6021
6170
|
allOf:
|
|
6022
6171
|
- $ref: "#/components/schemas/User"
|
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.36. Do not edit. */
|
|
2
2
|
export interface paths {
|
|
3
3
|
"/meta": {
|
|
4
4
|
parameters: {
|
|
@@ -945,6 +945,93 @@ export interface paths {
|
|
|
945
945
|
patch?: never;
|
|
946
946
|
trace?: never;
|
|
947
947
|
};
|
|
948
|
+
"/users/{user_id}/report": {
|
|
949
|
+
parameters: {
|
|
950
|
+
query?: never;
|
|
951
|
+
header?: {
|
|
952
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
953
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
954
|
+
/** @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`). */
|
|
955
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
956
|
+
};
|
|
957
|
+
path: {
|
|
958
|
+
user_id: components["parameters"]["UserId"];
|
|
959
|
+
};
|
|
960
|
+
cookie?: never;
|
|
961
|
+
};
|
|
962
|
+
get?: never;
|
|
963
|
+
put?: never;
|
|
964
|
+
/**
|
|
965
|
+
* Report a user
|
|
966
|
+
* @description One active report per reporter and user; reporting again changes the reason and the note. The reported user
|
|
967
|
+
* never learns who reported them. `block` (default `true`) also blocks the user, like
|
|
968
|
+
* `PUT /me/blocked-users/{user_id}`. Reporting yourself is `422`. At most 20 reports a day (`429`).
|
|
969
|
+
* Reports drive the reported user's account status automatically (`GET /me/account-status`).
|
|
970
|
+
*/
|
|
971
|
+
post: operations["reportUser"];
|
|
972
|
+
/**
|
|
973
|
+
* Withdraw a report
|
|
974
|
+
* @description Withdraws the current user's report on the user. Withdrawing a report that does not exist is fine.
|
|
975
|
+
*/
|
|
976
|
+
delete: operations["unreportUser"];
|
|
977
|
+
options?: never;
|
|
978
|
+
head?: never;
|
|
979
|
+
patch?: never;
|
|
980
|
+
trace?: never;
|
|
981
|
+
};
|
|
982
|
+
"/me/account-status": {
|
|
983
|
+
parameters: {
|
|
984
|
+
query?: never;
|
|
985
|
+
header?: {
|
|
986
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
987
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
988
|
+
/** @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`). */
|
|
989
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
990
|
+
};
|
|
991
|
+
path?: never;
|
|
992
|
+
cookie?: never;
|
|
993
|
+
};
|
|
994
|
+
/**
|
|
995
|
+
* The current user's account status
|
|
996
|
+
* @description The status follows the reports on the account automatically (`docs/moderation.md`). `restrictions` lists
|
|
997
|
+
* what the status blocks. The WebSocket event `account_status` carries the same object when it changes.
|
|
998
|
+
*/
|
|
999
|
+
get: operations["getAccountStatus"];
|
|
1000
|
+
put?: never;
|
|
1001
|
+
post?: never;
|
|
1002
|
+
delete?: never;
|
|
1003
|
+
options?: never;
|
|
1004
|
+
head?: never;
|
|
1005
|
+
patch?: never;
|
|
1006
|
+
trace?: never;
|
|
1007
|
+
};
|
|
1008
|
+
"/me/account-status/appeal": {
|
|
1009
|
+
parameters: {
|
|
1010
|
+
query?: never;
|
|
1011
|
+
header?: {
|
|
1012
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
1013
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
1014
|
+
/** @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`). */
|
|
1015
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
1016
|
+
};
|
|
1017
|
+
path?: never;
|
|
1018
|
+
cookie?: never;
|
|
1019
|
+
};
|
|
1020
|
+
get?: never;
|
|
1021
|
+
put?: never;
|
|
1022
|
+
/**
|
|
1023
|
+
* Appeal the account status
|
|
1024
|
+
* @description Automatic appeal (probation): the status drops one level for 14 days. Without a new weighted report in that
|
|
1025
|
+
* time the lower level stays; a new one restores the status and blocks appeals for 90 days. Allowed once per
|
|
1026
|
+
* 30 days and only when `can_appeal` is `true`, otherwise `409`.
|
|
1027
|
+
*/
|
|
1028
|
+
post: operations["appealAccountStatus"];
|
|
1029
|
+
delete?: never;
|
|
1030
|
+
options?: never;
|
|
1031
|
+
head?: never;
|
|
1032
|
+
patch?: never;
|
|
1033
|
+
trace?: never;
|
|
1034
|
+
};
|
|
948
1035
|
"/users/{user_id}/avatar": {
|
|
949
1036
|
parameters: {
|
|
950
1037
|
query?: never;
|
|
@@ -3847,7 +3934,7 @@ export interface components {
|
|
|
3847
3934
|
* codes must be treated like `internal_error`.
|
|
3848
3935
|
* @enum {string}
|
|
3849
3936
|
*/
|
|
3850
|
-
ErrorCode: "invalid_request" | "validation_failed" | "unauthenticated" | "invalid_credentials" | "two_factor_required" | "invalid_two_factor_code" | "token_expired" | "forbidden" | "not_found" | "conflict" | "already_exists" | "payload_too_large" | "unsupported_media_type" | "rate_limited" | "client_outdated" | "invalid_client_version" | "blocked_by_user" | "approval_required" | "user_verification_required" | "session_too_new" | "calls_unavailable" | "calls_not_allowed" | "call_identity_required" | "call_full" | "call_ended" | "already_in_call" | "stale_epoch" | "limit_reached" | "internal_error";
|
|
3937
|
+
ErrorCode: "invalid_request" | "validation_failed" | "unauthenticated" | "invalid_credentials" | "two_factor_required" | "invalid_two_factor_code" | "token_expired" | "forbidden" | "not_found" | "conflict" | "already_exists" | "payload_too_large" | "unsupported_media_type" | "rate_limited" | "client_outdated" | "invalid_client_version" | "blocked_by_user" | "approval_required" | "user_verification_required" | "session_too_new" | "calls_unavailable" | "calls_not_allowed" | "call_identity_required" | "call_full" | "call_ended" | "already_in_call" | "stale_epoch" | "limit_reached" | "account_restricted" | "internal_error";
|
|
3851
3938
|
/** @description RFC 9457 problem details. `426 Upgrade Required` (`client_outdated`) uses the same format. */
|
|
3852
3939
|
Problem: {
|
|
3853
3940
|
/**
|
|
@@ -3870,6 +3957,8 @@ export interface components {
|
|
|
3870
3957
|
min_client_api_version?: string;
|
|
3871
3958
|
/** @description Present when `code` is `client_outdated`. */
|
|
3872
3959
|
api_version?: string;
|
|
3960
|
+
/** @description Present when `code` is `account_restricted` (`403`); names what the account status blocks. */
|
|
3961
|
+
restriction?: components["schemas"]["AccountRestriction"];
|
|
3873
3962
|
} & {
|
|
3874
3963
|
[key: string]: unknown;
|
|
3875
3964
|
};
|
|
@@ -4205,6 +4294,47 @@ export interface components {
|
|
|
4205
4294
|
* videos (their `voice_video_messages` setting and exceptions). Absent everywhere else.
|
|
4206
4295
|
*/
|
|
4207
4296
|
can_send_voice_video?: boolean;
|
|
4297
|
+
/**
|
|
4298
|
+
* @description `restricted` when the account is suspended by its automatic account status; clients show "Restricted
|
|
4299
|
+
* account". Absent otherwise.
|
|
4300
|
+
*/
|
|
4301
|
+
account_label?: components["schemas"]["AccountLabel"];
|
|
4302
|
+
};
|
|
4303
|
+
/** @enum {string} */
|
|
4304
|
+
AccountLabel: "restricted";
|
|
4305
|
+
/** @enum {string} */
|
|
4306
|
+
ReportReason: "spam" | "scam" | "harassment" | "impersonation" | "inappropriate_profile" | "other";
|
|
4307
|
+
ReportUserRequest: {
|
|
4308
|
+
reason: components["schemas"]["ReportReason"];
|
|
4309
|
+
/** @description Optional details for the report. Never shown to the reported user. */
|
|
4310
|
+
note?: string | null;
|
|
4311
|
+
/**
|
|
4312
|
+
* @description Also block the user.
|
|
4313
|
+
* @default true
|
|
4314
|
+
*/
|
|
4315
|
+
block: boolean;
|
|
4316
|
+
};
|
|
4317
|
+
/**
|
|
4318
|
+
* @description `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
|
|
4319
|
+
* new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
|
|
4320
|
+
* and emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).
|
|
4321
|
+
* Unknown values must be treated like `restricted`.
|
|
4322
|
+
* @enum {string}
|
|
4323
|
+
*/
|
|
4324
|
+
AccountStatusLevel: "good" | "warned" | "limited" | "restricted" | "suspended";
|
|
4325
|
+
/**
|
|
4326
|
+
* @description An action the account status blocks. Unknown values must be shown as a generic restriction.
|
|
4327
|
+
* @enum {string}
|
|
4328
|
+
*/
|
|
4329
|
+
AccountRestriction: "start_direct" | "invite_to_group" | "call" | "create_group" | "upload" | "forward" | "edit_profile" | "publish_pack" | "search" | "send" | "manage_group";
|
|
4330
|
+
AccountStatus: {
|
|
4331
|
+
status: components["schemas"]["AccountStatusLevel"];
|
|
4332
|
+
/** @description When the account reached this status; `null` when it never changed. */
|
|
4333
|
+
since: components["schemas"]["Timestamp"] | null;
|
|
4334
|
+
restrictions: components["schemas"]["AccountRestriction"][];
|
|
4335
|
+
can_appeal: boolean;
|
|
4336
|
+
/** @description End of the running probation after an appeal; `null` when none runs. */
|
|
4337
|
+
probation_until: components["schemas"]["Timestamp"] | null;
|
|
4208
4338
|
};
|
|
4209
4339
|
Me: components["schemas"]["User"] & {
|
|
4210
4340
|
created_at: components["schemas"]["Timestamp"];
|
|
@@ -5189,7 +5319,7 @@ export interface components {
|
|
|
5189
5319
|
"application/problem+json": components["schemas"]["Problem"];
|
|
5190
5320
|
};
|
|
5191
5321
|
};
|
|
5192
|
-
/** @description Authenticated but not allowed */
|
|
5322
|
+
/** @description Authenticated but not allowed. `account_restricted` (with `restriction`) when the account status blocks the action. */
|
|
5193
5323
|
Forbidden: {
|
|
5194
5324
|
headers: {
|
|
5195
5325
|
[name: string]: unknown;
|
|
@@ -5749,6 +5879,7 @@ export interface operations {
|
|
|
5749
5879
|
};
|
|
5750
5880
|
400: components["responses"]["BadRequest"];
|
|
5751
5881
|
401: components["responses"]["Unauthorized"];
|
|
5882
|
+
403: components["responses"]["Forbidden"];
|
|
5752
5883
|
422: components["responses"]["ValidationFailed"];
|
|
5753
5884
|
426: components["responses"]["ClientOutdated"];
|
|
5754
5885
|
};
|
|
@@ -5782,6 +5913,7 @@ export interface operations {
|
|
|
5782
5913
|
};
|
|
5783
5914
|
400: components["responses"]["BadRequest"];
|
|
5784
5915
|
401: components["responses"]["Unauthorized"];
|
|
5916
|
+
403: components["responses"]["Forbidden"];
|
|
5785
5917
|
404: components["responses"]["NotFound"];
|
|
5786
5918
|
426: components["responses"]["ClientOutdated"];
|
|
5787
5919
|
};
|
|
@@ -5847,6 +5979,7 @@ export interface operations {
|
|
|
5847
5979
|
};
|
|
5848
5980
|
400: components["responses"]["BadRequest"];
|
|
5849
5981
|
401: components["responses"]["Unauthorized"];
|
|
5982
|
+
403: components["responses"]["Forbidden"];
|
|
5850
5983
|
422: components["responses"]["ValidationFailed"];
|
|
5851
5984
|
426: components["responses"]["ClientOutdated"];
|
|
5852
5985
|
};
|
|
@@ -5907,6 +6040,7 @@ export interface operations {
|
|
|
5907
6040
|
};
|
|
5908
6041
|
400: components["responses"]["BadRequest"];
|
|
5909
6042
|
401: components["responses"]["Unauthorized"];
|
|
6043
|
+
403: components["responses"]["Forbidden"];
|
|
5910
6044
|
422: components["responses"]["ValidationFailed"];
|
|
5911
6045
|
426: components["responses"]["ClientOutdated"];
|
|
5912
6046
|
};
|
|
@@ -6802,6 +6936,126 @@ export interface operations {
|
|
|
6802
6936
|
429: components["responses"]["TooManyRequests"];
|
|
6803
6937
|
};
|
|
6804
6938
|
};
|
|
6939
|
+
reportUser: {
|
|
6940
|
+
parameters: {
|
|
6941
|
+
query?: never;
|
|
6942
|
+
header?: {
|
|
6943
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
6944
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
6945
|
+
/** @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`). */
|
|
6946
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
6947
|
+
};
|
|
6948
|
+
path: {
|
|
6949
|
+
user_id: components["parameters"]["UserId"];
|
|
6950
|
+
};
|
|
6951
|
+
cookie?: never;
|
|
6952
|
+
};
|
|
6953
|
+
requestBody: {
|
|
6954
|
+
content: {
|
|
6955
|
+
"application/json": components["schemas"]["ReportUserRequest"];
|
|
6956
|
+
};
|
|
6957
|
+
};
|
|
6958
|
+
responses: {
|
|
6959
|
+
/** @description Reported */
|
|
6960
|
+
204: {
|
|
6961
|
+
headers: {
|
|
6962
|
+
[name: string]: unknown;
|
|
6963
|
+
};
|
|
6964
|
+
content?: never;
|
|
6965
|
+
};
|
|
6966
|
+
400: components["responses"]["BadRequest"];
|
|
6967
|
+
401: components["responses"]["Unauthorized"];
|
|
6968
|
+
404: components["responses"]["NotFound"];
|
|
6969
|
+
422: components["responses"]["ValidationFailed"];
|
|
6970
|
+
426: components["responses"]["ClientOutdated"];
|
|
6971
|
+
429: components["responses"]["TooManyRequests"];
|
|
6972
|
+
};
|
|
6973
|
+
};
|
|
6974
|
+
unreportUser: {
|
|
6975
|
+
parameters: {
|
|
6976
|
+
query?: never;
|
|
6977
|
+
header?: {
|
|
6978
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
6979
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
6980
|
+
/** @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`). */
|
|
6981
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
6982
|
+
};
|
|
6983
|
+
path: {
|
|
6984
|
+
user_id: components["parameters"]["UserId"];
|
|
6985
|
+
};
|
|
6986
|
+
cookie?: never;
|
|
6987
|
+
};
|
|
6988
|
+
requestBody?: never;
|
|
6989
|
+
responses: {
|
|
6990
|
+
/** @description Withdrawn */
|
|
6991
|
+
204: {
|
|
6992
|
+
headers: {
|
|
6993
|
+
[name: string]: unknown;
|
|
6994
|
+
};
|
|
6995
|
+
content?: never;
|
|
6996
|
+
};
|
|
6997
|
+
400: components["responses"]["BadRequest"];
|
|
6998
|
+
401: components["responses"]["Unauthorized"];
|
|
6999
|
+
426: components["responses"]["ClientOutdated"];
|
|
7000
|
+
};
|
|
7001
|
+
};
|
|
7002
|
+
getAccountStatus: {
|
|
7003
|
+
parameters: {
|
|
7004
|
+
query?: never;
|
|
7005
|
+
header?: {
|
|
7006
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
7007
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
7008
|
+
/** @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`). */
|
|
7009
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
7010
|
+
};
|
|
7011
|
+
path?: never;
|
|
7012
|
+
cookie?: never;
|
|
7013
|
+
};
|
|
7014
|
+
requestBody?: never;
|
|
7015
|
+
responses: {
|
|
7016
|
+
/** @description The account status */
|
|
7017
|
+
200: {
|
|
7018
|
+
headers: {
|
|
7019
|
+
[name: string]: unknown;
|
|
7020
|
+
};
|
|
7021
|
+
content: {
|
|
7022
|
+
"application/json": components["schemas"]["AccountStatus"];
|
|
7023
|
+
};
|
|
7024
|
+
};
|
|
7025
|
+
400: components["responses"]["BadRequest"];
|
|
7026
|
+
401: components["responses"]["Unauthorized"];
|
|
7027
|
+
426: components["responses"]["ClientOutdated"];
|
|
7028
|
+
};
|
|
7029
|
+
};
|
|
7030
|
+
appealAccountStatus: {
|
|
7031
|
+
parameters: {
|
|
7032
|
+
query?: never;
|
|
7033
|
+
header?: {
|
|
7034
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
7035
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
7036
|
+
/** @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`). */
|
|
7037
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
7038
|
+
};
|
|
7039
|
+
path?: never;
|
|
7040
|
+
cookie?: never;
|
|
7041
|
+
};
|
|
7042
|
+
requestBody?: never;
|
|
7043
|
+
responses: {
|
|
7044
|
+
/** @description The new account status */
|
|
7045
|
+
200: {
|
|
7046
|
+
headers: {
|
|
7047
|
+
[name: string]: unknown;
|
|
7048
|
+
};
|
|
7049
|
+
content: {
|
|
7050
|
+
"application/json": components["schemas"]["AccountStatus"];
|
|
7051
|
+
};
|
|
7052
|
+
};
|
|
7053
|
+
400: components["responses"]["BadRequest"];
|
|
7054
|
+
401: components["responses"]["Unauthorized"];
|
|
7055
|
+
409: components["responses"]["Conflict"];
|
|
7056
|
+
426: components["responses"]["ClientOutdated"];
|
|
7057
|
+
};
|
|
7058
|
+
};
|
|
6805
7059
|
getUserAvatar: {
|
|
6806
7060
|
parameters: {
|
|
6807
7061
|
query?: {
|
|
@@ -7000,6 +7254,7 @@ export interface operations {
|
|
|
7000
7254
|
};
|
|
7001
7255
|
400: components["responses"]["BadRequest"];
|
|
7002
7256
|
401: components["responses"]["Unauthorized"];
|
|
7257
|
+
403: components["responses"]["Forbidden"];
|
|
7003
7258
|
413: components["responses"]["PayloadTooLarge"];
|
|
7004
7259
|
415: components["responses"]["UnsupportedMediaType"];
|
|
7005
7260
|
426: components["responses"]["ClientOutdated"];
|
|
@@ -7144,6 +7399,7 @@ export interface operations {
|
|
|
7144
7399
|
};
|
|
7145
7400
|
400: components["responses"]["BadRequest"];
|
|
7146
7401
|
401: components["responses"]["Unauthorized"];
|
|
7402
|
+
403: components["responses"]["Forbidden"];
|
|
7147
7403
|
413: components["responses"]["PayloadTooLarge"];
|
|
7148
7404
|
426: components["responses"]["ClientOutdated"];
|
|
7149
7405
|
429: components["responses"]["TooManyRequests"];
|
|
@@ -8873,6 +9129,7 @@ export interface operations {
|
|
|
8873
9129
|
};
|
|
8874
9130
|
400: components["responses"]["BadRequest"];
|
|
8875
9131
|
401: components["responses"]["Unauthorized"];
|
|
9132
|
+
403: components["responses"]["Forbidden"];
|
|
8876
9133
|
409: components["responses"]["Conflict"];
|
|
8877
9134
|
422: components["responses"]["ValidationFailed"];
|
|
8878
9135
|
426: components["responses"]["ClientOutdated"];
|
|
@@ -9307,6 +9564,7 @@ export interface operations {
|
|
|
9307
9564
|
};
|
|
9308
9565
|
400: components["responses"]["BadRequest"];
|
|
9309
9566
|
401: components["responses"]["Unauthorized"];
|
|
9567
|
+
403: components["responses"]["Forbidden"];
|
|
9310
9568
|
422: components["responses"]["ValidationFailed"];
|
|
9311
9569
|
426: components["responses"]["ClientOutdated"];
|
|
9312
9570
|
};
|
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| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\n| `attachment_updated` | An optimized copy of an attachment you can see is ready (or failed): replace it in your messages |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
2
|
+
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`, and `data.field` when one setting or field caused it (for example `voice_video_messages`). `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\r\n| `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",
|
|
@@ -70,6 +70,22 @@
|
|
|
70
70
|
"action": "recording_voice"
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
+
"server/account_status.json": {
|
|
74
|
+
"type": "account_status",
|
|
75
|
+
"event_id": "7217400317439950011",
|
|
76
|
+
"chat_id": null,
|
|
77
|
+
"data": {
|
|
78
|
+
"status": "limited",
|
|
79
|
+
"since": "2026-11-18T09:30:00Z",
|
|
80
|
+
"restrictions": [
|
|
81
|
+
"start_direct",
|
|
82
|
+
"invite_to_group",
|
|
83
|
+
"call"
|
|
84
|
+
],
|
|
85
|
+
"can_appeal": true,
|
|
86
|
+
"probation_until": null
|
|
87
|
+
}
|
|
88
|
+
},
|
|
73
89
|
"server/ack.json": {
|
|
74
90
|
"type": "ack",
|
|
75
91
|
"event_id": "7217400317439950009",
|
package/dist/ws-events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.36. Do not edit. */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Any WebSocket event, in either direction.
|
|
@@ -32,6 +32,7 @@ export type AttachmentRef = string;
|
|
|
32
32
|
* Every event the server may send.
|
|
33
33
|
*/
|
|
34
34
|
export type ServerEvent =
|
|
35
|
+
| ServerAccountStatusEvent
|
|
35
36
|
| ServerAckEvent
|
|
36
37
|
| ServerApprovalRequestCreatedEvent
|
|
37
38
|
| ServerAttachmentUpdatedEvent
|
|
@@ -57,7 +58,30 @@ export type ServerEvent =
|
|
|
57
58
|
| ServerSecurityNoticeEvent
|
|
58
59
|
| ServerTypingEvent
|
|
59
60
|
| ServerUserUpdatedEvent;
|
|
61
|
+
/**
|
|
62
|
+
* `good` no restrictions, `warned` no restrictions yet, `limited` no new contact with non-contacts and at most 5
|
|
63
|
+
* new direct chats a day, `restricted` also no groups, uploads, forwarded files, profile changes or sticker
|
|
64
|
+
* and emoji packs and hidden from search, `suspended` read-only (no sending, joining calls or managing groups).
|
|
65
|
+
* Unknown values must be treated like `restricted`.
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
export type AccountStatusLevel = "good" | "warned" | "limited" | "restricted" | "suspended";
|
|
60
69
|
export type Timestamp = string;
|
|
70
|
+
/**
|
|
71
|
+
* An action the account status blocks. Unknown values must be shown as a generic restriction.
|
|
72
|
+
*/
|
|
73
|
+
export type AccountRestriction =
|
|
74
|
+
| "start_direct"
|
|
75
|
+
| "invite_to_group"
|
|
76
|
+
| "call"
|
|
77
|
+
| "create_group"
|
|
78
|
+
| "upload"
|
|
79
|
+
| "forward"
|
|
80
|
+
| "edit_profile"
|
|
81
|
+
| "publish_pack"
|
|
82
|
+
| "search"
|
|
83
|
+
| "send"
|
|
84
|
+
| "manage_group";
|
|
61
85
|
export type ApprovalRequestType = "direct_message" | "group_invite";
|
|
62
86
|
export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
|
|
63
87
|
export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
|
|
@@ -74,6 +98,7 @@ export type ProfileBackgroundKind = "media" | "preset" | "color";
|
|
|
74
98
|
export type BackgroundPreset = string;
|
|
75
99
|
export type BackgroundColor = string;
|
|
76
100
|
export type Username = string;
|
|
101
|
+
export type AccountLabel = "restricted";
|
|
77
102
|
/**
|
|
78
103
|
* `ringing` until someone answers, `active` while people are in it, `ended` afterwards.
|
|
79
104
|
*/
|
|
@@ -137,6 +162,7 @@ export type ErrorCode =
|
|
|
137
162
|
| "already_in_call"
|
|
138
163
|
| "stale_epoch"
|
|
139
164
|
| "limit_reached"
|
|
165
|
+
| "account_restricted"
|
|
140
166
|
| "internal_error";
|
|
141
167
|
|
|
142
168
|
/**
|
|
@@ -256,6 +282,28 @@ export interface ClientTypingEvent {
|
|
|
256
282
|
"typing" | "recording_voice" | "choosing_sticker" | "uploading_photo" | "uploading_video" | "uploading_file";
|
|
257
283
|
};
|
|
258
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* The current user's account status changed (sent only to the user's own sessions).
|
|
287
|
+
*/
|
|
288
|
+
export interface ServerAccountStatusEvent {
|
|
289
|
+
type: "account_status";
|
|
290
|
+
event_id: Id;
|
|
291
|
+
chat_id: null;
|
|
292
|
+
data: AccountStatus;
|
|
293
|
+
}
|
|
294
|
+
export interface AccountStatus {
|
|
295
|
+
status: AccountStatusLevel;
|
|
296
|
+
/**
|
|
297
|
+
* When the account reached this status; `null` when it never changed.
|
|
298
|
+
*/
|
|
299
|
+
since: Timestamp | null;
|
|
300
|
+
restrictions: AccountRestriction[];
|
|
301
|
+
can_appeal: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* End of the running probation after an appeal; `null` when none runs.
|
|
304
|
+
*/
|
|
305
|
+
probation_until: Timestamp | null;
|
|
306
|
+
}
|
|
259
307
|
/**
|
|
260
308
|
* The server accepted the client event with this `client_temp_id`.
|
|
261
309
|
*/
|
|
@@ -354,6 +402,12 @@ export interface User {
|
|
|
354
402
|
*
|
|
355
403
|
*/
|
|
356
404
|
can_send_voice_video?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* `restricted` when the account is suspended by its automatic account status; clients show "Restricted
|
|
407
|
+
* account". Absent otherwise.
|
|
408
|
+
*
|
|
409
|
+
*/
|
|
410
|
+
account_label?: AccountLabel;
|
|
357
411
|
}
|
|
358
412
|
export interface Birthday {
|
|
359
413
|
day: number;
|
|
@@ -844,6 +898,21 @@ export interface ServerErrorEvent {
|
|
|
844
898
|
data: {
|
|
845
899
|
code: ErrorCode;
|
|
846
900
|
message?: string;
|
|
901
|
+
/**
|
|
902
|
+
* An action the account status blocks. Unknown values must be shown as a generic restriction.
|
|
903
|
+
*/
|
|
904
|
+
restriction?:
|
|
905
|
+
| "start_direct"
|
|
906
|
+
| "invite_to_group"
|
|
907
|
+
| "call"
|
|
908
|
+
| "create_group"
|
|
909
|
+
| "upload"
|
|
910
|
+
| "forward"
|
|
911
|
+
| "edit_profile"
|
|
912
|
+
| "publish_pack"
|
|
913
|
+
| "search"
|
|
914
|
+
| "send"
|
|
915
|
+
| "manage_group";
|
|
847
916
|
/**
|
|
848
917
|
* The setting or field that caused the error, for example `voice_video_messages` for a voice message or video the recipient does not accept.
|
|
849
918
|
*/
|
|
@@ -216,6 +216,7 @@
|
|
|
216
216
|
"already_in_call",
|
|
217
217
|
"stale_epoch",
|
|
218
218
|
"limit_reached",
|
|
219
|
+
"account_restricted",
|
|
219
220
|
"internal_error"
|
|
220
221
|
]
|
|
221
222
|
},
|
|
@@ -278,6 +279,14 @@
|
|
|
278
279
|
"api_version": {
|
|
279
280
|
"type": "string",
|
|
280
281
|
"description": "Present when `code` is `client_outdated`."
|
|
282
|
+
},
|
|
283
|
+
"restriction": {
|
|
284
|
+
"allOf": [
|
|
285
|
+
{
|
|
286
|
+
"$ref": "#/$defs/AccountRestriction"
|
|
287
|
+
}
|
|
288
|
+
],
|
|
289
|
+
"description": "Present when `code` is `account_restricted` (`403`); names what the account status blocks."
|
|
281
290
|
}
|
|
282
291
|
},
|
|
283
292
|
"additionalProperties": true
|
|
@@ -1359,6 +1368,130 @@
|
|
|
1359
1368
|
"can_send_voice_video": {
|
|
1360
1369
|
"type": "boolean",
|
|
1361
1370
|
"description": "Only on `Chat.peer` of a direct chat: whether the requesting user may send this user voice messages and\nvideos (their `voice_video_messages` setting and exceptions). Absent everywhere else.\n"
|
|
1371
|
+
},
|
|
1372
|
+
"account_label": {
|
|
1373
|
+
"allOf": [
|
|
1374
|
+
{
|
|
1375
|
+
"$ref": "#/$defs/AccountLabel"
|
|
1376
|
+
}
|
|
1377
|
+
],
|
|
1378
|
+
"description": "`restricted` when the account is suspended by its automatic account status; clients show \"Restricted\naccount\". Absent otherwise.\n"
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
"AccountLabel": {
|
|
1383
|
+
"type": "string",
|
|
1384
|
+
"enum": [
|
|
1385
|
+
"restricted"
|
|
1386
|
+
]
|
|
1387
|
+
},
|
|
1388
|
+
"ReportReason": {
|
|
1389
|
+
"type": "string",
|
|
1390
|
+
"enum": [
|
|
1391
|
+
"spam",
|
|
1392
|
+
"scam",
|
|
1393
|
+
"harassment",
|
|
1394
|
+
"impersonation",
|
|
1395
|
+
"inappropriate_profile",
|
|
1396
|
+
"other"
|
|
1397
|
+
]
|
|
1398
|
+
},
|
|
1399
|
+
"ReportUserRequest": {
|
|
1400
|
+
"type": "object",
|
|
1401
|
+
"required": [
|
|
1402
|
+
"reason"
|
|
1403
|
+
],
|
|
1404
|
+
"properties": {
|
|
1405
|
+
"reason": {
|
|
1406
|
+
"$ref": "#/$defs/ReportReason"
|
|
1407
|
+
},
|
|
1408
|
+
"note": {
|
|
1409
|
+
"type": [
|
|
1410
|
+
"string",
|
|
1411
|
+
"null"
|
|
1412
|
+
],
|
|
1413
|
+
"maxLength": 500,
|
|
1414
|
+
"description": "Optional details for the report. Never shown to the reported user."
|
|
1415
|
+
},
|
|
1416
|
+
"block": {
|
|
1417
|
+
"type": "boolean",
|
|
1418
|
+
"default": true,
|
|
1419
|
+
"description": "Also block the user."
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
"additionalProperties": false
|
|
1423
|
+
},
|
|
1424
|
+
"AccountStatusLevel": {
|
|
1425
|
+
"type": "string",
|
|
1426
|
+
"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",
|
|
1427
|
+
"enum": [
|
|
1428
|
+
"good",
|
|
1429
|
+
"warned",
|
|
1430
|
+
"limited",
|
|
1431
|
+
"restricted",
|
|
1432
|
+
"suspended"
|
|
1433
|
+
]
|
|
1434
|
+
},
|
|
1435
|
+
"AccountRestriction": {
|
|
1436
|
+
"type": "string",
|
|
1437
|
+
"description": "An action the account status blocks. Unknown values must be shown as a generic restriction.",
|
|
1438
|
+
"enum": [
|
|
1439
|
+
"start_direct",
|
|
1440
|
+
"invite_to_group",
|
|
1441
|
+
"call",
|
|
1442
|
+
"create_group",
|
|
1443
|
+
"upload",
|
|
1444
|
+
"forward",
|
|
1445
|
+
"edit_profile",
|
|
1446
|
+
"publish_pack",
|
|
1447
|
+
"search",
|
|
1448
|
+
"send",
|
|
1449
|
+
"manage_group"
|
|
1450
|
+
]
|
|
1451
|
+
},
|
|
1452
|
+
"AccountStatus": {
|
|
1453
|
+
"type": "object",
|
|
1454
|
+
"required": [
|
|
1455
|
+
"status",
|
|
1456
|
+
"since",
|
|
1457
|
+
"restrictions",
|
|
1458
|
+
"can_appeal",
|
|
1459
|
+
"probation_until"
|
|
1460
|
+
],
|
|
1461
|
+
"properties": {
|
|
1462
|
+
"status": {
|
|
1463
|
+
"$ref": "#/$defs/AccountStatusLevel"
|
|
1464
|
+
},
|
|
1465
|
+
"since": {
|
|
1466
|
+
"description": "When the account reached this status; `null` when it never changed.",
|
|
1467
|
+
"oneOf": [
|
|
1468
|
+
{
|
|
1469
|
+
"$ref": "#/$defs/Timestamp"
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
"type": "null"
|
|
1473
|
+
}
|
|
1474
|
+
]
|
|
1475
|
+
},
|
|
1476
|
+
"restrictions": {
|
|
1477
|
+
"type": "array",
|
|
1478
|
+
"items": {
|
|
1479
|
+
"$ref": "#/$defs/AccountRestriction"
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
"can_appeal": {
|
|
1483
|
+
"type": "boolean"
|
|
1484
|
+
},
|
|
1485
|
+
"probation_until": {
|
|
1486
|
+
"description": "End of the running probation after an appeal; `null` when none runs.",
|
|
1487
|
+
"oneOf": [
|
|
1488
|
+
{
|
|
1489
|
+
"$ref": "#/$defs/Timestamp"
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
"type": "null"
|
|
1493
|
+
}
|
|
1494
|
+
]
|
|
1362
1495
|
}
|
|
1363
1496
|
}
|
|
1364
1497
|
},
|
|
@@ -5254,6 +5387,31 @@
|
|
|
5254
5387
|
],
|
|
5255
5388
|
"additionalProperties": false
|
|
5256
5389
|
},
|
|
5390
|
+
"ServerAccountStatusEvent": {
|
|
5391
|
+
"title": "ServerAccountStatusEvent",
|
|
5392
|
+
"description": "The current user's account status changed (sent only to the user's own sessions).",
|
|
5393
|
+
"type": "object",
|
|
5394
|
+
"required": [
|
|
5395
|
+
"type",
|
|
5396
|
+
"event_id",
|
|
5397
|
+
"chat_id",
|
|
5398
|
+
"data"
|
|
5399
|
+
],
|
|
5400
|
+
"properties": {
|
|
5401
|
+
"type": {
|
|
5402
|
+
"const": "account_status"
|
|
5403
|
+
},
|
|
5404
|
+
"event_id": {
|
|
5405
|
+
"$ref": "#/$defs/Id"
|
|
5406
|
+
},
|
|
5407
|
+
"chat_id": {
|
|
5408
|
+
"type": "null"
|
|
5409
|
+
},
|
|
5410
|
+
"data": {
|
|
5411
|
+
"$ref": "#/$defs/AccountStatus"
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
},
|
|
5257
5415
|
"ServerAckEvent": {
|
|
5258
5416
|
"title": "ServerAckEvent",
|
|
5259
5417
|
"description": "The server accepted the client event with this `client_temp_id`.",
|
|
@@ -5641,6 +5799,10 @@
|
|
|
5641
5799
|
"message": {
|
|
5642
5800
|
"type": "string"
|
|
5643
5801
|
},
|
|
5802
|
+
"restriction": {
|
|
5803
|
+
"description": "Present when `code` is `account_restricted`.",
|
|
5804
|
+
"$ref": "#/$defs/AccountRestriction"
|
|
5805
|
+
},
|
|
5644
5806
|
"field": {
|
|
5645
5807
|
"type": "string",
|
|
5646
5808
|
"description": "The setting or field that caused the error, for example `voice_video_messages` for a voice message or video the recipient does not accept."
|
|
@@ -6293,6 +6455,9 @@
|
|
|
6293
6455
|
"title": "ServerEvent",
|
|
6294
6456
|
"description": "Every event the server may send.",
|
|
6295
6457
|
"oneOf": [
|
|
6458
|
+
{
|
|
6459
|
+
"$ref": "#/$defs/ServerAccountStatusEvent"
|
|
6460
|
+
},
|
|
6296
6461
|
{
|
|
6297
6462
|
"$ref": "#/$defs/ServerAckEvent"
|
|
6298
6463
|
},
|
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.36.next.127",
|
|
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": {
|