@myronsi/messenger-api 2.1.0-alpha.58.next.204 → 2.1.0-alpha.59.next.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,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.59
6
+
7
+ - Built-in comments on channel posts, two levels deep. `SendMessageRequest.thread_root_id` (and the WebSocket
8
+ `message` event) sends a comment; `reply_to` to another comment makes it a reply. `Message` gains
9
+ `thread_root_id`, `parent_id`, `comment_count` and `comments_enabled`.
10
+ - `GET /chats/{chat_id}/messages/{message_id}/comments` pages a post's comments or a comment's replies;
11
+ `PUT /chats/{chat_id}/messages/{message_id}/comments-enabled` turns comments off for one post.
12
+ - `Group` and `UpdateGroupRequest` gain `comments_enabled` and `comment_slow_mode` (`CommentSlowMode`); `Group` gains
13
+ `notify_comments`. New `PUT /groups/{chat_id}/comment-notifications`, `GET /groups/{chat_id}/comment-bans` and
14
+ `PUT`/`DELETE /groups/{chat_id}/comment-bans/{user_id}`.
15
+ - WebSocket: client events `thread_open` and `thread_close` (`message_id` of the post); new, edited and deleted
16
+ comments go only to users who have the thread open (re-send `thread_open` at least every 2 minutes).
17
+ `post_stats` items gain `comment_count` and, for posts, `comments_enabled`.
18
+ - Search: `searchMessages` gains `in` (`all`, `posts`, `comments`); `searchAllMessages` gains `chat_kind=channel` and
19
+ `include_comments`. `searchPublicGroups` gains `mode`, and `q` is optional (`mode=channel` lists public channels).
20
+
5
21
  ## 2.1.0-alpha.58
6
22
 
7
23
  - Channel post stats: `Message` gains `view_count` and `reaction_counts` (`ReactionCount`: `emoji`, `count`), both
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.58. Do not edit. */
2
- export declare const API_VERSION: "2.1.0-alpha.58";
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.59. Do not edit. */
2
+ export declare const API_VERSION: "2.1.0-alpha.59";
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.58";
1
+ export const API_VERSION = "2.1.0-alpha.59";
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.58
4
+ version: 2.1.0-alpha.59
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
@@ -2231,6 +2231,7 @@ paths:
2231
2231
  unread_count: { type: integer, minimum: 0 }
2232
2232
  "401": { $ref: "#/components/responses/Unauthorized" }
2233
2233
  "404": { $ref: "#/components/responses/NotFound" }
2234
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2234
2235
  /chats/{chat_id}/messages:
2235
2236
  parameters:
2236
2237
  - $ref: "#/components/parameters/ClientVersion"
@@ -2360,11 +2361,16 @@ paths:
2360
2361
  tags: [chats]
2361
2362
  operationId: searchMessages
2362
2363
  summary: Search messages in a chat
2364
+ description: In a channel the search covers posts and comments; `in` narrows it. Comment hits carry `thread_root_id`.
2363
2365
  parameters:
2364
2366
  - name: q
2365
2367
  in: query
2366
2368
  required: true
2367
2369
  schema: { type: string, minLength: 2, maxLength: 256 }
2370
+ - name: in
2371
+ in: query
2372
+ required: false
2373
+ schema: { $ref: "#/components/schemas/MessageSearchScope" }
2368
2374
  - $ref: "#/components/parameters/Limit"
2369
2375
  - $ref: "#/components/parameters/After"
2370
2376
  responses:
@@ -2379,6 +2385,67 @@ paths:
2379
2385
  "404": { $ref: "#/components/responses/NotFound" }
2380
2386
  "422": { $ref: "#/components/responses/ValidationFailed" }
2381
2387
  "429": { $ref: "#/components/responses/TooManyRequests" }
2388
+ /chats/{chat_id}/messages/{message_id}/comments:
2389
+ parameters:
2390
+ - $ref: "#/components/parameters/ClientVersion"
2391
+ - $ref: "#/components/parameters/ClientApiVersion"
2392
+ - $ref: "#/components/parameters/ChatId"
2393
+ - $ref: "#/components/parameters/MessageId"
2394
+ get:
2395
+ tags: [chats]
2396
+ operationId: listComments
2397
+ summary: Comments of a channel post, or replies of a top-level comment
2398
+ description: |
2399
+ For a post: its top-level comments. For a top-level comment: its replies. Items are ordered oldest to newest;
2400
+ `after` pages forward (send `after=1` to start at the first comment), `before` backward, `around` opens at a
2401
+ comment. Without a cursor the newest comments are returned. Every member of the channel may read them.
2402
+ parameters:
2403
+ - $ref: "#/components/parameters/Limit"
2404
+ - name: before
2405
+ in: query
2406
+ schema: { $ref: "#/components/schemas/Id" }
2407
+ - name: after
2408
+ in: query
2409
+ schema: { $ref: "#/components/schemas/Id" }
2410
+ - name: around
2411
+ in: query
2412
+ schema: { $ref: "#/components/schemas/Id" }
2413
+ responses:
2414
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2415
+ "400": { $ref: "#/components/responses/BadRequest" }
2416
+ "200":
2417
+ description: A page of comments
2418
+ content:
2419
+ application/json:
2420
+ schema: { $ref: "#/components/schemas/MessagePage" }
2421
+ "401": { $ref: "#/components/responses/Unauthorized" }
2422
+ "404": { $ref: "#/components/responses/NotFound" }
2423
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2424
+ /chats/{chat_id}/messages/{message_id}/comments-enabled:
2425
+ parameters:
2426
+ - $ref: "#/components/parameters/ClientVersion"
2427
+ - $ref: "#/components/parameters/ClientApiVersion"
2428
+ - $ref: "#/components/parameters/ChatId"
2429
+ - $ref: "#/components/parameters/MessageId"
2430
+ put:
2431
+ tags: [chats]
2432
+ operationId: setPostComments
2433
+ summary: Turn comments on or off for one channel post
2434
+ description: Owner and admins only. Existing comments stay readable.
2435
+ requestBody:
2436
+ required: true
2437
+ content:
2438
+ application/json:
2439
+ schema: { $ref: "#/components/schemas/CommentsEnabledRequest" }
2440
+ responses:
2441
+ "426": { $ref: "#/components/responses/ClientOutdated" }
2442
+ "400": { $ref: "#/components/responses/BadRequest" }
2443
+ "204":
2444
+ description: Changed
2445
+ "401": { $ref: "#/components/responses/Unauthorized" }
2446
+ "403": { $ref: "#/components/responses/Forbidden" }
2447
+ "404": { $ref: "#/components/responses/NotFound" }
2448
+ "422": { $ref: "#/components/responses/ValidationFailed" }
2382
2449
  /chats/{chat_id}/media:
2383
2450
  parameters:
2384
2451
  - $ref: "#/components/parameters/ClientVersion"
@@ -3018,6 +3085,16 @@ paths:
3018
3085
  in: query
3019
3086
  description: Words to find; optional with `kind`
3020
3087
  schema: { type: string, minLength: 2, maxLength: 256 }
3088
+ - name: chat_kind
3089
+ in: query
3090
+ required: false
3091
+ description: "`channel` keeps only posts of subscribed channels."
3092
+ schema: { $ref: "#/components/schemas/SearchChatKind" }
3093
+ - name: include_comments
3094
+ in: query
3095
+ required: false
3096
+ description: Also search the comments of channel posts. Off by default.
3097
+ schema: { type: boolean, default: false }
3021
3098
  - name: kind
3022
3099
  in: query
3023
3100
  description: Only messages with this kind of attachment, or with a web link (`link`)
@@ -3741,6 +3818,87 @@ paths:
3741
3818
  "401": { $ref: "#/components/responses/Unauthorized" }
3742
3819
  "403": { $ref: "#/components/responses/Forbidden" }
3743
3820
  "404": { $ref: "#/components/responses/NotFound" }
3821
+ /groups/{chat_id}/comment-bans:
3822
+ parameters:
3823
+ - $ref: "#/components/parameters/ClientVersion"
3824
+ - $ref: "#/components/parameters/ClientApiVersion"
3825
+ - $ref: "#/components/parameters/ChatId"
3826
+ get:
3827
+ tags: [groups]
3828
+ operationId: listCommentBans
3829
+ summary: Subscribers who may not comment in the channel
3830
+ description: Owner, admins and moderators only. Newest first.
3831
+ parameters:
3832
+ - $ref: "#/components/parameters/Limit"
3833
+ - $ref: "#/components/parameters/After"
3834
+ responses:
3835
+ "426": { $ref: "#/components/responses/ClientOutdated" }
3836
+ "400": { $ref: "#/components/responses/BadRequest" }
3837
+ "200":
3838
+ description: A page of comment bans
3839
+ content:
3840
+ application/json:
3841
+ schema: { $ref: "#/components/schemas/GroupBanPage" }
3842
+ "401": { $ref: "#/components/responses/Unauthorized" }
3843
+ "403": { $ref: "#/components/responses/Forbidden" }
3844
+ "404": { $ref: "#/components/responses/NotFound" }
3845
+ /groups/{chat_id}/comment-bans/{user_id}:
3846
+ parameters:
3847
+ - $ref: "#/components/parameters/ClientVersion"
3848
+ - $ref: "#/components/parameters/ClientApiVersion"
3849
+ - $ref: "#/components/parameters/ChatId"
3850
+ - $ref: "#/components/parameters/UserId"
3851
+ put:
3852
+ tags: [groups]
3853
+ operationId: banCommenter
3854
+ summary: Stop a subscriber from commenting
3855
+ description: Owner, admins and moderators only. The subscriber keeps reading the channel. Idempotent.
3856
+ responses:
3857
+ "426": { $ref: "#/components/responses/ClientOutdated" }
3858
+ "400": { $ref: "#/components/responses/BadRequest" }
3859
+ "204":
3860
+ description: Banned from commenting
3861
+ "401": { $ref: "#/components/responses/Unauthorized" }
3862
+ "403": { $ref: "#/components/responses/Forbidden" }
3863
+ "404": { $ref: "#/components/responses/NotFound" }
3864
+ delete:
3865
+ tags: [groups]
3866
+ operationId: unbanCommenter
3867
+ summary: Let a subscriber comment again
3868
+ description: Owner, admins and moderators only. Idempotent.
3869
+ responses:
3870
+ "426": { $ref: "#/components/responses/ClientOutdated" }
3871
+ "400": { $ref: "#/components/responses/BadRequest" }
3872
+ "204":
3873
+ description: Lifted
3874
+ "401": { $ref: "#/components/responses/Unauthorized" }
3875
+ "403": { $ref: "#/components/responses/Forbidden" }
3876
+ "404": { $ref: "#/components/responses/NotFound" }
3877
+ /groups/{chat_id}/comment-notifications:
3878
+ parameters:
3879
+ - $ref: "#/components/parameters/ClientVersion"
3880
+ - $ref: "#/components/parameters/ClientApiVersion"
3881
+ - $ref: "#/components/parameters/ChatId"
3882
+ put:
3883
+ tags: [groups]
3884
+ operationId: setCommentNotifications
3885
+ summary: Get a push for every new comment on your own posts
3886
+ description: |
3887
+ Off by default. Without it you get pushes only for replies to your comments and for mentions. Only useful
3888
+ for the owner and admins, who post.
3889
+ requestBody:
3890
+ required: true
3891
+ content:
3892
+ application/json:
3893
+ schema: { $ref: "#/components/schemas/CommentsEnabledRequest" }
3894
+ responses:
3895
+ "426": { $ref: "#/components/responses/ClientOutdated" }
3896
+ "400": { $ref: "#/components/responses/BadRequest" }
3897
+ "204":
3898
+ description: Changed
3899
+ "401": { $ref: "#/components/responses/Unauthorized" }
3900
+ "404": { $ref: "#/components/responses/NotFound" }
3901
+ "422": { $ref: "#/components/responses/ValidationFailed" }
3744
3902
  /invites/{token}:
3745
3903
  parameters:
3746
3904
  - $ref: "#/components/parameters/ClientVersion"
@@ -3799,11 +3957,16 @@ paths:
3799
3957
  tags: [groups]
3800
3958
  operationId: searchPublicGroups
3801
3959
  summary: Search public groups by public name or group name
3960
+ description: Send `q`, `mode` or both. `mode=channel` without `q` lists every public channel, for "Discover".
3802
3961
  parameters:
3803
3962
  - name: q
3804
3963
  in: query
3805
- required: true
3964
+ required: false
3806
3965
  schema: { type: string, minLength: 2, maxLength: 64 }
3966
+ - name: mode
3967
+ in: query
3968
+ required: false
3969
+ schema: { $ref: "#/components/schemas/GroupMode" }
3807
3970
  - $ref: "#/components/parameters/Limit"
3808
3971
  - $ref: "#/components/parameters/After"
3809
3972
  responses:
@@ -8835,6 +8998,25 @@ components:
8835
8998
  author's own reads do not count. `post_stats` events update it.
8836
8999
  type: [integer, "null"]
8837
9000
  minimum: 0
9001
+ thread_root_id:
9002
+ description: Set on a comment of a channel post (the post it belongs to); `null` for posts and other messages.
9003
+ oneOf:
9004
+ - $ref: "#/components/schemas/Id"
9005
+ - type: "null"
9006
+ parent_id:
9007
+ description: Set on a reply inside a comment thread (the top-level comment it hangs under); `null` otherwise.
9008
+ oneOf:
9009
+ - $ref: "#/components/schemas/Id"
9010
+ - type: "null"
9011
+ comment_count:
9012
+ description: |
9013
+ Channel posts: all comments and replies. Top-level comments: their replies. `null` elsewhere. `post_stats`
9014
+ events update it.
9015
+ type: [integer, "null"]
9016
+ minimum: 0
9017
+ comments_enabled:
9018
+ description: Channel posts only (`null` elsewhere) - whether new comments are accepted on this post.
9019
+ type: [boolean, "null"]
8838
9020
  read_by:
8839
9021
  type: array
8840
9022
  items: { $ref: "#/components/schemas/ReadReceipt" }
@@ -9213,6 +9395,13 @@ components:
9213
9395
  maxItems: 10
9214
9396
  uniqueItems: true
9215
9397
  items: { $ref: "#/components/schemas/AttachmentRef" }
9398
+ thread_root_id:
9399
+ description: |
9400
+ Sends a comment on this channel post instead of a post. Every subscriber may comment unless comments are
9401
+ off for the channel or the post (`403`), the caller is banned from commenting (`403`), or slow mode holds
9402
+ (`429`). `reply_to` may name another comment of the same post: the comment is then a reply, listed under
9403
+ that comment's top-level comment. Polls cannot be comments.
9404
+ $ref: "#/components/schemas/Id"
9216
9405
  reply_to:
9217
9406
  oneOf:
9218
9407
  - $ref: "#/components/schemas/Id"
@@ -9768,6 +9957,13 @@ components:
9768
9957
  properties:
9769
9958
  id: { $ref: "#/components/schemas/Id" }
9770
9959
  group_mode: { $ref: "#/components/schemas/GroupMode" }
9960
+ comments_enabled:
9961
+ type: boolean
9962
+ description: Channels only - whether subscribers may comment on posts.
9963
+ comment_slow_mode: { $ref: "#/components/schemas/CommentSlowMode" }
9964
+ notify_comments:
9965
+ type: boolean
9966
+ description: Channels only - whether the caller gets a push for every new comment on their own posts.
9771
9967
  member_count:
9772
9968
  type: integer
9773
9969
  minimum: 0
@@ -9813,6 +10009,27 @@ components:
9813
10009
  properties:
9814
10010
  name: { type: string, minLength: 1, maxLength: 64 }
9815
10011
  description: { type: [string, "null"], maxLength: 500 }
10012
+ comments_enabled:
10013
+ type: boolean
10014
+ description: Channels only - whether subscribers may comment on posts.
10015
+ comment_slow_mode: { $ref: "#/components/schemas/CommentSlowMode" }
10016
+ CommentSlowMode:
10017
+ type: integer
10018
+ description: Channels only - seconds a subscriber waits between two comments; 0 is off. Owner, admins and moderators are exempt.
10019
+ enum: [0, 10, 30, 60, 300, 900, 3600]
10020
+ MessageSearchScope:
10021
+ type: string
10022
+ description: Inside a channel - `all` (posts and comments, the default), `posts` or `comments`.
10023
+ enum: [all, posts, comments]
10024
+ SearchChatKind:
10025
+ type: string
10026
+ description: "`channel` keeps only subscribed channels."
10027
+ enum: [channel]
10028
+ CommentsEnabledRequest:
10029
+ type: object
10030
+ required: [enabled]
10031
+ properties:
10032
+ enabled: { type: boolean }
9816
10033
  AddParticipantRequest:
9817
10034
  type: object
9818
10035
  required: [user_id]
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.58. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.59. Do not edit. */
2
2
  export interface paths {
3
3
  "/meta": {
4
4
  parameters: {
@@ -2080,7 +2080,10 @@ export interface paths {
2080
2080
  };
2081
2081
  cookie?: never;
2082
2082
  };
2083
- /** Search messages in a chat */
2083
+ /**
2084
+ * Search messages in a chat
2085
+ * @description In a channel the search covers posts and comments; `in` narrows it. Comment hits carry `thread_root_id`.
2086
+ */
2084
2087
  get: operations["searchMessages"];
2085
2088
  put?: never;
2086
2089
  post?: never;
@@ -2090,6 +2093,64 @@ export interface paths {
2090
2093
  patch?: never;
2091
2094
  trace?: never;
2092
2095
  };
2096
+ "/chats/{chat_id}/messages/{message_id}/comments": {
2097
+ parameters: {
2098
+ query?: never;
2099
+ header?: {
2100
+ /** @description Version of the client app, for logs and the per-client metric. */
2101
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
2102
+ /** @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`). */
2103
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
2104
+ };
2105
+ path: {
2106
+ chat_id: components["parameters"]["ChatId"];
2107
+ message_id: components["parameters"]["MessageId"];
2108
+ };
2109
+ cookie?: never;
2110
+ };
2111
+ /**
2112
+ * Comments of a channel post, or replies of a top-level comment
2113
+ * @description For a post: its top-level comments. For a top-level comment: its replies. Items are ordered oldest to newest;
2114
+ * `after` pages forward (send `after=1` to start at the first comment), `before` backward, `around` opens at a
2115
+ * comment. Without a cursor the newest comments are returned. Every member of the channel may read them.
2116
+ */
2117
+ get: operations["listComments"];
2118
+ put?: never;
2119
+ post?: never;
2120
+ delete?: never;
2121
+ options?: never;
2122
+ head?: never;
2123
+ patch?: never;
2124
+ trace?: never;
2125
+ };
2126
+ "/chats/{chat_id}/messages/{message_id}/comments-enabled": {
2127
+ parameters: {
2128
+ query?: never;
2129
+ header?: {
2130
+ /** @description Version of the client app, for logs and the per-client metric. */
2131
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
2132
+ /** @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`). */
2133
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
2134
+ };
2135
+ path: {
2136
+ chat_id: components["parameters"]["ChatId"];
2137
+ message_id: components["parameters"]["MessageId"];
2138
+ };
2139
+ cookie?: never;
2140
+ };
2141
+ get?: never;
2142
+ /**
2143
+ * Turn comments on or off for one channel post
2144
+ * @description Owner and admins only. Existing comments stay readable.
2145
+ */
2146
+ put: operations["setPostComments"];
2147
+ post?: never;
2148
+ delete?: never;
2149
+ options?: never;
2150
+ head?: never;
2151
+ patch?: never;
2152
+ trace?: never;
2153
+ };
2093
2154
  "/chats/{chat_id}/media": {
2094
2155
  parameters: {
2095
2156
  query?: never;
@@ -3228,6 +3289,93 @@ export interface paths {
3228
3289
  patch?: never;
3229
3290
  trace?: never;
3230
3291
  };
3292
+ "/groups/{chat_id}/comment-bans": {
3293
+ parameters: {
3294
+ query?: never;
3295
+ header?: {
3296
+ /** @description Version of the client app, for logs and the per-client metric. */
3297
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
3298
+ /** @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`). */
3299
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
3300
+ };
3301
+ path: {
3302
+ chat_id: components["parameters"]["ChatId"];
3303
+ };
3304
+ cookie?: never;
3305
+ };
3306
+ /**
3307
+ * Subscribers who may not comment in the channel
3308
+ * @description Owner, admins and moderators only. Newest first.
3309
+ */
3310
+ get: operations["listCommentBans"];
3311
+ put?: never;
3312
+ post?: never;
3313
+ delete?: never;
3314
+ options?: never;
3315
+ head?: never;
3316
+ patch?: never;
3317
+ trace?: never;
3318
+ };
3319
+ "/groups/{chat_id}/comment-bans/{user_id}": {
3320
+ parameters: {
3321
+ query?: never;
3322
+ header?: {
3323
+ /** @description Version of the client app, for logs and the per-client metric. */
3324
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
3325
+ /** @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`). */
3326
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
3327
+ };
3328
+ path: {
3329
+ chat_id: components["parameters"]["ChatId"];
3330
+ user_id: components["parameters"]["UserId"];
3331
+ };
3332
+ cookie?: never;
3333
+ };
3334
+ get?: never;
3335
+ /**
3336
+ * Stop a subscriber from commenting
3337
+ * @description Owner, admins and moderators only. The subscriber keeps reading the channel. Idempotent.
3338
+ */
3339
+ put: operations["banCommenter"];
3340
+ post?: never;
3341
+ /**
3342
+ * Let a subscriber comment again
3343
+ * @description Owner, admins and moderators only. Idempotent.
3344
+ */
3345
+ delete: operations["unbanCommenter"];
3346
+ options?: never;
3347
+ head?: never;
3348
+ patch?: never;
3349
+ trace?: never;
3350
+ };
3351
+ "/groups/{chat_id}/comment-notifications": {
3352
+ parameters: {
3353
+ query?: never;
3354
+ header?: {
3355
+ /** @description Version of the client app, for logs and the per-client metric. */
3356
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
3357
+ /** @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`). */
3358
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
3359
+ };
3360
+ path: {
3361
+ chat_id: components["parameters"]["ChatId"];
3362
+ };
3363
+ cookie?: never;
3364
+ };
3365
+ get?: never;
3366
+ /**
3367
+ * Get a push for every new comment on your own posts
3368
+ * @description Off by default. Without it you get pushes only for replies to your comments and for mentions. Only useful
3369
+ * for the owner and admins, who post.
3370
+ */
3371
+ put: operations["setCommentNotifications"];
3372
+ post?: never;
3373
+ delete?: never;
3374
+ options?: never;
3375
+ head?: never;
3376
+ patch?: never;
3377
+ trace?: never;
3378
+ };
3231
3379
  "/invites/{token}": {
3232
3380
  parameters: {
3233
3381
  query?: never;
@@ -3298,7 +3446,10 @@ export interface paths {
3298
3446
  path?: never;
3299
3447
  cookie?: never;
3300
3448
  };
3301
- /** Search public groups by public name or group name */
3449
+ /**
3450
+ * Search public groups by public name or group name
3451
+ * @description Send `q`, `mode` or both. `mode=channel` without `q` lists every public channel, for "Discover".
3452
+ */
3302
3453
  get: operations["searchPublicGroups"];
3303
3454
  put?: never;
3304
3455
  post?: never;
@@ -6522,6 +6673,17 @@ export interface components {
6522
6673
  * author's own reads do not count. `post_stats` events update it.
6523
6674
  */
6524
6675
  view_count?: number | null;
6676
+ /** @description Set on a comment of a channel post (the post it belongs to); `null` for posts and other messages. */
6677
+ thread_root_id?: components["schemas"]["Id"] | null;
6678
+ /** @description Set on a reply inside a comment thread (the top-level comment it hangs under); `null` otherwise. */
6679
+ parent_id?: components["schemas"]["Id"] | null;
6680
+ /**
6681
+ * @description Channel posts: all comments and replies. Top-level comments: their replies. `null` elsewhere. `post_stats`
6682
+ * events update it.
6683
+ */
6684
+ comment_count?: number | null;
6685
+ /** @description Channel posts only (`null` elsewhere) - whether new comments are accepted on this post. */
6686
+ comments_enabled?: boolean | null;
6525
6687
  read_by: components["schemas"]["ReadReceipt"][];
6526
6688
  /** @description When the message was sent; for an imported message, when it was sent in the other messenger. */
6527
6689
  created_at: components["schemas"]["Timestamp"];
@@ -6768,6 +6930,13 @@ export interface components {
6768
6930
  attachment_id?: components["schemas"]["AttachmentRef"] | null;
6769
6931
  /** @description Ordered IDs of two to ten image or video uploads for one file message. */
6770
6932
  attachment_ids?: components["schemas"]["AttachmentRef"][];
6933
+ /**
6934
+ * @description Sends a comment on this channel post instead of a post. Every subscriber may comment unless comments are
6935
+ * off for the channel or the post (`403`), the caller is banned from commenting (`403`), or slow mode holds
6936
+ * (`429`). `reply_to` may name another comment of the same post: the comment is then a reply, listed under
6937
+ * that comment's top-level comment. Polls cannot be comments.
6938
+ */
6939
+ thread_root_id?: components["schemas"]["Id"];
6771
6940
  reply_to?: components["schemas"]["Id"] | null;
6772
6941
  /**
6773
6942
  * @description Drawings on images of a `file` message, at most one per image. Each `attachment_id` must be one of the
@@ -7045,6 +7214,11 @@ export interface components {
7045
7214
  Group: {
7046
7215
  id: components["schemas"]["Id"];
7047
7216
  group_mode: components["schemas"]["GroupMode"];
7217
+ /** @description Channels only - whether subscribers may comment on posts. */
7218
+ comments_enabled?: boolean;
7219
+ comment_slow_mode?: components["schemas"]["CommentSlowMode"];
7220
+ /** @description Channels only - whether the caller gets a push for every new comment on their own posts. */
7221
+ notify_comments?: boolean;
7048
7222
  /** @description Everyone in the group, the owner included (the subscribers of a channel). */
7049
7223
  member_count: number;
7050
7224
  name: string;
@@ -7070,6 +7244,27 @@ export interface components {
7070
7244
  UpdateGroupRequest: {
7071
7245
  name?: string;
7072
7246
  description?: string | null;
7247
+ /** @description Channels only - whether subscribers may comment on posts. */
7248
+ comments_enabled?: boolean;
7249
+ comment_slow_mode?: components["schemas"]["CommentSlowMode"];
7250
+ };
7251
+ /**
7252
+ * @description Channels only - seconds a subscriber waits between two comments; 0 is off. Owner, admins and moderators are exempt.
7253
+ * @enum {integer}
7254
+ */
7255
+ CommentSlowMode: 0 | 10 | 30 | 60 | 300 | 900 | 3600;
7256
+ /**
7257
+ * @description Inside a channel - `all` (posts and comments, the default), `posts` or `comments`.
7258
+ * @enum {string}
7259
+ */
7260
+ MessageSearchScope: "all" | "posts" | "comments";
7261
+ /**
7262
+ * @description `channel` keeps only subscribed channels.
7263
+ * @enum {string}
7264
+ */
7265
+ SearchChatKind: "channel";
7266
+ CommentsEnabledRequest: {
7267
+ enabled: boolean;
7073
7268
  };
7074
7269
  AddParticipantRequest: {
7075
7270
  user_id: components["schemas"]["Id"];
@@ -10805,6 +11000,7 @@ export interface operations {
10805
11000
  400: components["responses"]["BadRequest"];
10806
11001
  401: components["responses"]["Unauthorized"];
10807
11002
  404: components["responses"]["NotFound"];
11003
+ 422: components["responses"]["ValidationFailed"];
10808
11004
  426: components["responses"]["ClientOutdated"];
10809
11005
  };
10810
11006
  };
@@ -10963,6 +11159,7 @@ export interface operations {
10963
11159
  parameters: {
10964
11160
  query: {
10965
11161
  q: string;
11162
+ in?: components["schemas"]["MessageSearchScope"];
10966
11163
  /** @description Page size */
10967
11164
  limit?: components["parameters"]["Limit"];
10968
11165
  /** @description Opaque `next_cursor` of the previous page */
@@ -10998,6 +11195,81 @@ export interface operations {
10998
11195
  429: components["responses"]["TooManyRequests"];
10999
11196
  };
11000
11197
  };
11198
+ listComments: {
11199
+ parameters: {
11200
+ query?: {
11201
+ /** @description Page size */
11202
+ limit?: components["parameters"]["Limit"];
11203
+ before?: components["schemas"]["Id"];
11204
+ after?: components["schemas"]["Id"];
11205
+ around?: components["schemas"]["Id"];
11206
+ };
11207
+ header?: {
11208
+ /** @description Version of the client app, for logs and the per-client metric. */
11209
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
11210
+ /** @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`). */
11211
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
11212
+ };
11213
+ path: {
11214
+ chat_id: components["parameters"]["ChatId"];
11215
+ message_id: components["parameters"]["MessageId"];
11216
+ };
11217
+ cookie?: never;
11218
+ };
11219
+ requestBody?: never;
11220
+ responses: {
11221
+ /** @description A page of comments */
11222
+ 200: {
11223
+ headers: {
11224
+ [name: string]: unknown;
11225
+ };
11226
+ content: {
11227
+ "application/json": components["schemas"]["MessagePage"];
11228
+ };
11229
+ };
11230
+ 400: components["responses"]["BadRequest"];
11231
+ 401: components["responses"]["Unauthorized"];
11232
+ 404: components["responses"]["NotFound"];
11233
+ 422: components["responses"]["ValidationFailed"];
11234
+ 426: components["responses"]["ClientOutdated"];
11235
+ };
11236
+ };
11237
+ setPostComments: {
11238
+ parameters: {
11239
+ query?: never;
11240
+ header?: {
11241
+ /** @description Version of the client app, for logs and the per-client metric. */
11242
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
11243
+ /** @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`). */
11244
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
11245
+ };
11246
+ path: {
11247
+ chat_id: components["parameters"]["ChatId"];
11248
+ message_id: components["parameters"]["MessageId"];
11249
+ };
11250
+ cookie?: never;
11251
+ };
11252
+ requestBody: {
11253
+ content: {
11254
+ "application/json": components["schemas"]["CommentsEnabledRequest"];
11255
+ };
11256
+ };
11257
+ responses: {
11258
+ /** @description Changed */
11259
+ 204: {
11260
+ headers: {
11261
+ [name: string]: unknown;
11262
+ };
11263
+ content?: never;
11264
+ };
11265
+ 400: components["responses"]["BadRequest"];
11266
+ 401: components["responses"]["Unauthorized"];
11267
+ 403: components["responses"]["Forbidden"];
11268
+ 404: components["responses"]["NotFound"];
11269
+ 422: components["responses"]["ValidationFailed"];
11270
+ 426: components["responses"]["ClientOutdated"];
11271
+ };
11272
+ };
11001
11273
  listChatMedia: {
11002
11274
  parameters: {
11003
11275
  query: {
@@ -11783,6 +12055,10 @@ export interface operations {
11783
12055
  query?: {
11784
12056
  /** @description Words to find; optional with `kind` */
11785
12057
  q?: string;
12058
+ /** @description `channel` keeps only posts of subscribed channels. */
12059
+ chat_kind?: components["schemas"]["SearchChatKind"];
12060
+ /** @description Also search the comments of channel posts. Off by default. */
12061
+ include_comments?: boolean;
11786
12062
  /** @description Only messages with this kind of attachment, or with a web link (`link`) */
11787
12063
  kind?: components["schemas"]["MediaKind"];
11788
12064
  /** @description Only this chat */
@@ -12856,6 +13132,139 @@ export interface operations {
12856
13132
  426: components["responses"]["ClientOutdated"];
12857
13133
  };
12858
13134
  };
13135
+ listCommentBans: {
13136
+ parameters: {
13137
+ query?: {
13138
+ /** @description Page size */
13139
+ limit?: components["parameters"]["Limit"];
13140
+ /** @description Opaque `next_cursor` of the previous page */
13141
+ after?: components["parameters"]["After"];
13142
+ };
13143
+ header?: {
13144
+ /** @description Version of the client app, for logs and the per-client metric. */
13145
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
13146
+ /** @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`). */
13147
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
13148
+ };
13149
+ path: {
13150
+ chat_id: components["parameters"]["ChatId"];
13151
+ };
13152
+ cookie?: never;
13153
+ };
13154
+ requestBody?: never;
13155
+ responses: {
13156
+ /** @description A page of comment bans */
13157
+ 200: {
13158
+ headers: {
13159
+ [name: string]: unknown;
13160
+ };
13161
+ content: {
13162
+ "application/json": components["schemas"]["GroupBanPage"];
13163
+ };
13164
+ };
13165
+ 400: components["responses"]["BadRequest"];
13166
+ 401: components["responses"]["Unauthorized"];
13167
+ 403: components["responses"]["Forbidden"];
13168
+ 404: components["responses"]["NotFound"];
13169
+ 426: components["responses"]["ClientOutdated"];
13170
+ };
13171
+ };
13172
+ banCommenter: {
13173
+ parameters: {
13174
+ query?: never;
13175
+ header?: {
13176
+ /** @description Version of the client app, for logs and the per-client metric. */
13177
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
13178
+ /** @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`). */
13179
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
13180
+ };
13181
+ path: {
13182
+ chat_id: components["parameters"]["ChatId"];
13183
+ user_id: components["parameters"]["UserId"];
13184
+ };
13185
+ cookie?: never;
13186
+ };
13187
+ requestBody?: never;
13188
+ responses: {
13189
+ /** @description Banned from commenting */
13190
+ 204: {
13191
+ headers: {
13192
+ [name: string]: unknown;
13193
+ };
13194
+ content?: never;
13195
+ };
13196
+ 400: components["responses"]["BadRequest"];
13197
+ 401: components["responses"]["Unauthorized"];
13198
+ 403: components["responses"]["Forbidden"];
13199
+ 404: components["responses"]["NotFound"];
13200
+ 426: components["responses"]["ClientOutdated"];
13201
+ };
13202
+ };
13203
+ unbanCommenter: {
13204
+ parameters: {
13205
+ query?: never;
13206
+ header?: {
13207
+ /** @description Version of the client app, for logs and the per-client metric. */
13208
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
13209
+ /** @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`). */
13210
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
13211
+ };
13212
+ path: {
13213
+ chat_id: components["parameters"]["ChatId"];
13214
+ user_id: components["parameters"]["UserId"];
13215
+ };
13216
+ cookie?: never;
13217
+ };
13218
+ requestBody?: never;
13219
+ responses: {
13220
+ /** @description Lifted */
13221
+ 204: {
13222
+ headers: {
13223
+ [name: string]: unknown;
13224
+ };
13225
+ content?: never;
13226
+ };
13227
+ 400: components["responses"]["BadRequest"];
13228
+ 401: components["responses"]["Unauthorized"];
13229
+ 403: components["responses"]["Forbidden"];
13230
+ 404: components["responses"]["NotFound"];
13231
+ 426: components["responses"]["ClientOutdated"];
13232
+ };
13233
+ };
13234
+ setCommentNotifications: {
13235
+ parameters: {
13236
+ query?: never;
13237
+ header?: {
13238
+ /** @description Version of the client app, for logs and the per-client metric. */
13239
+ "X-Client-Version"?: components["parameters"]["ClientVersion"];
13240
+ /** @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`). */
13241
+ "X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
13242
+ };
13243
+ path: {
13244
+ chat_id: components["parameters"]["ChatId"];
13245
+ };
13246
+ cookie?: never;
13247
+ };
13248
+ requestBody: {
13249
+ content: {
13250
+ "application/json": components["schemas"]["CommentsEnabledRequest"];
13251
+ };
13252
+ };
13253
+ responses: {
13254
+ /** @description Changed */
13255
+ 204: {
13256
+ headers: {
13257
+ [name: string]: unknown;
13258
+ };
13259
+ content?: never;
13260
+ };
13261
+ 400: components["responses"]["BadRequest"];
13262
+ 401: components["responses"]["Unauthorized"];
13263
+ 404: components["responses"]["NotFound"];
13264
+ 422: components["responses"]["ValidationFailed"];
13265
+ 426: components["responses"]["ClientOutdated"];
13266
+ };
13267
+ };
12859
13268
  getInvite: {
12860
13269
  parameters: {
12861
13270
  query?: never;
@@ -12924,8 +13333,9 @@ export interface operations {
12924
13333
  };
12925
13334
  searchPublicGroups: {
12926
13335
  parameters: {
12927
- query: {
12928
- q: string;
13336
+ query?: {
13337
+ q?: string;
13338
+ mode?: components["schemas"]["GroupMode"];
12929
13339
  /** @description Page size */
12930
13340
  limit?: components["parameters"]["Limit"];
12931
13341
  /** @description Opaque `next_cursor` of the previous page */
package/dist/ws-docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "markdown": "# WebSocket protocol (API contract v2)\n\n\n\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`).\n\n\n\n## Connecting\n\n\n\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.\n\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.\n\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.\n\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`.\n\n\n\n## Close codes\n\n\n\n| Code | Meaning | Client |\n\n| --- | --- | --- |\n\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) |\n\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 |\n\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\n\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\n\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\n\n\n\n## Envelope\n\n\n\nServer → client:\n\n\n\n```json\n\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\n\n```\n\n\n\nClient → server:\n\n\n\n```json\n\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\n\n```\n\n\n\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\n\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\n\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.\n\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\n\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\n\n\n\n## Acknowledgements\n\n\n\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:\n\n\n\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.\n\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).\n\n\n\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).\n\n\n\n## Client → server events\n\n\n\n| Type | Purpose |\n\n| --- | --- |\n\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\n\n| `resend` | Deliver a stored but undelivered message again |\n\n| `edit` | Edit your own text message |\n\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\n\n| `read` | Mark messages as read up to `message_id` |\n\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\n\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 |\n\n\n\n## Server → client events\n\n\n\n| Type | Meaning |\n\n| --- | --- |\n\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\n\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\n\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`) |\n\n| `reaction_add`, `reaction_remove` | Reactions changed (in a channel only to the reacting user's own sessions) |\n| `post_stats` | Channels: merged `view_count` and `reaction_counts` of posts, at most one per post every 10 s, to online subscribers |\n\n| `read` | A user read up to `message_id` |\n\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 |\n\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 |\n\n| `pin_update` | A message was pinned or unpinned for everyone (to all members) or only for you (`scope: me`, to your own sessions); carries `pinned_message_count` for you |\n\n| `poll_updated` | A vote changed or a poll closed; carries the whole `Poll` as you see it (results only once you voted, for the creator, or after closing). Keep the highest `version` |\n\n| `import_update` | An imported history of the chat started, finished or is being removed (to all members); reload the chat on `done` and `removing` |\n| `import_sender_update` | A name of an imported history was suggested for a member, declined, confirmed or withdrawn; suggestions and declines go only to the importer and that member |\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\n\n| `approval_request_created` | New request in the inbox |\n\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\n\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\n| `client_settings_updated` | Your synced appearance or recent emoji changed (`ClientSettings`); only your own sessions get it |\n| `wallpaper_updated` | One of your chat backgrounds changed or was removed (`WallpaperUpdatedEvent`); only your own sessions get it |\n| `playlists_updated` | One of your playlists was created, changed or deleted (`PlaylistsUpdatedEvent`); only your own sessions get it |\n\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`) |\n\n\n\n## Compatibility\n\n\n\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.\n\n",
2
+ "markdown": "# WebSocket protocol (API contract v2)\n\n\n\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`).\n\n\n\n## Connecting\n\n\n\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.\n\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.\n\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.\n\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`.\n\n\n\n## Close codes\n\n\n\n| Code | Meaning | Client |\n\n| --- | --- | --- |\n\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) |\n\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 |\n\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\n\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\n\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\n\n\n\n## Envelope\n\n\n\nServer → client:\n\n\n\n```json\n\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\n\n```\n\n\n\nClient → server:\n\n\n\n```json\n\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\n\n```\n\n\n\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\n\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\n\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.\n\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\n\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\n\n\n\n## Acknowledgements\n\n\n\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:\n\n\n\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.\n\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).\n\n\n\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).\n\n\n\n## Client → server events\n\n\n\n| Type | Purpose |\n\n| --- | --- |\n\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\n\n| `resend` | Deliver a stored but undelivered message again |\n\n| `edit` | Edit your own text message |\n\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\n\n| `read` | Mark messages as read up to `message_id` |\n\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\n| `thread_open`, `thread_close` | You opened or closed the comments of a channel post (`message_id`); comment events reach you only while it is open. Re-send `thread_open` at least every 2 minutes |\n\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 |\n\n\n\n## Server → client events\n\n\n\n| Type | Meaning |\n\n| --- | --- |\n\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\n\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\n\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`) |\n\n| `reaction_add`, `reaction_remove` | Reactions changed (in a channel only to the reacting user's own sessions) |\n| `post_stats` | Channels: merged `view_count`, `reaction_counts` and `comment_count` of posts (to online subscribers) and of comments (to users with the thread open), at most one per item every 10 s |\n\n| `read` | A user read up to `message_id` |\n\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 |\n\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 |\n\n| `pin_update` | A message was pinned or unpinned for everyone (to all members) or only for you (`scope: me`, to your own sessions); carries `pinned_message_count` for you |\n\n| `poll_updated` | A vote changed or a poll closed; carries the whole `Poll` as you see it (results only once you voted, for the creator, or after closing). Keep the highest `version` |\n\n| `import_update` | An imported history of the chat started, finished or is being removed (to all members); reload the chat on `done` and `removing` |\n| `import_sender_update` | A name of an imported history was suggested for a member, declined, confirmed or withdrawn; suggestions and declines go only to the importer and that member |\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\n\n| `approval_request_created` | New request in the inbox |\n\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\n\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\n| `client_settings_updated` | Your synced appearance or recent emoji changed (`ClientSettings`); only your own sessions get it |\n| `wallpaper_updated` | One of your chat backgrounds changed or was removed (`WallpaperUpdatedEvent`); only your own sessions get it |\n| `playlists_updated` | One of your playlists was created, changed or deleted (`PlaylistsUpdatedEvent`); only your own sessions get it |\n\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`) |\n\n\n\n## Compatibility\n\n\n\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.\n\n",
3
3
  "examples": {
4
4
  "client/delete.json": {
5
5
  "type": "delete",
@@ -62,6 +62,22 @@
62
62
  "message_id": "7217400317439950001"
63
63
  }
64
64
  },
65
+ "client/thread_close.json": {
66
+ "type": "thread_close",
67
+ "client_temp_id": "c-1",
68
+ "chat_id": "42",
69
+ "data": {
70
+ "message_id": "7217400317439950001"
71
+ }
72
+ },
73
+ "client/thread_open.json": {
74
+ "type": "thread_open",
75
+ "client_temp_id": "c-1",
76
+ "chat_id": "42",
77
+ "data": {
78
+ "message_id": "7217400317439950001"
79
+ }
80
+ },
65
81
  "client/typing.json": {
66
82
  "type": "typing",
67
83
  "chat_id": "42",
@@ -687,7 +703,9 @@
687
703
  "emoji": "🔥",
688
704
  "count": 12
689
705
  }
690
- ]
706
+ ],
707
+ "comment_count": 31,
708
+ "comments_enabled": true
691
709
  }
692
710
  ]
693
711
  }
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.58. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.59. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -15,6 +15,8 @@ export type ClientEvent =
15
15
  | ClientReactionRemoveEvent
16
16
  | ClientReadEvent
17
17
  | ClientResendEvent
18
+ | ClientThreadCloseEvent
19
+ | ClientThreadOpenEvent
18
20
  | ClientTypingEvent;
19
21
  /**
20
22
  * Client-generated ID that makes sending idempotent and ties acks and errors to the send.
@@ -221,6 +223,10 @@ export type ErrorCode =
221
223
  | "poll_closed"
222
224
  | "quiz_answered"
223
225
  | "internal_error";
226
+ /**
227
+ * Channels only - seconds a subscriber waits between two comments; 0 is off. Owner, admins and moderators are exempt.
228
+ */
229
+ export type CommentSlowMode = 0 | 10 | 30 | 60 | 300 | 900 | 3600;
224
230
  /**
225
231
  * A username or a group's public name. One name space for both, unique ignoring case; links are `/@name` on the
226
232
  * web app's origin.
@@ -298,6 +304,10 @@ export interface TextMessageData {
298
304
  type: "text";
299
305
  content: string;
300
306
  reply_to?: Id | null;
307
+ /**
308
+ * Decimal ID as a string (Snowflake IDs exceed 2^53).
309
+ */
310
+ thread_root_id?: string;
301
311
  }
302
312
  /**
303
313
  * `file` and `voice` messages reference an uploaded attachment by ID, never by URL.
@@ -310,6 +320,10 @@ export interface AttachmentMessageData {
310
320
  content?: string | null;
311
321
  attachment_id: AttachmentRef;
312
322
  reply_to?: Id | null;
323
+ /**
324
+ * Decimal ID as a string (Snowflake IDs exceed 2^53).
325
+ */
326
+ thread_root_id?: string;
313
327
  }
314
328
  /**
315
329
  * Add a reaction.
@@ -363,6 +377,28 @@ export interface ClientResendEvent {
363
377
  message_id: Id;
364
378
  };
365
379
  }
380
+ /**
381
+ * You stopped looking at the comments of this channel post.
382
+ */
383
+ export interface ClientThreadCloseEvent {
384
+ type: "thread_close";
385
+ client_temp_id: ClientTempId;
386
+ chat_id: Id;
387
+ data: {
388
+ message_id: Id;
389
+ };
390
+ }
391
+ /**
392
+ * You are looking at the comments of this channel post: new, edited and deleted comments are sent to you. Send it again at least every 2 minutes while the thread stays open.
393
+ */
394
+ export interface ClientThreadOpenEvent {
395
+ type: "thread_open";
396
+ client_temp_id: ClientTempId;
397
+ chat_id: Id;
398
+ data: {
399
+ message_id: Id;
400
+ };
401
+ }
366
402
  /**
367
403
  * Tell the chat that you are (not) typing, recording a voice message, choosing a sticker or sending a photo, video or file. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.
368
404
  */
@@ -904,6 +940,24 @@ export interface Message {
904
940
  *
905
941
  */
906
942
  view_count?: number | null;
943
+ /**
944
+ * Set on a comment of a channel post (the post it belongs to); `null` for posts and other messages.
945
+ */
946
+ thread_root_id?: Id | null;
947
+ /**
948
+ * Set on a reply inside a comment thread (the top-level comment it hangs under); `null` otherwise.
949
+ */
950
+ parent_id?: Id | null;
951
+ /**
952
+ * Channel posts: all comments and replies. Top-level comments: their replies. `null` elsewhere. `post_stats`
953
+ * events update it.
954
+ *
955
+ */
956
+ comment_count?: number | null;
957
+ /**
958
+ * Channel posts only (`null` elsewhere) - whether new comments are accepted on this post.
959
+ */
960
+ comments_enabled?: boolean | null;
907
961
  read_by: ReadReceipt[];
908
962
  /**
909
963
  * When the message was sent; for an imported message, when it was sent in the other messenger.
@@ -1352,6 +1406,15 @@ export interface ServerGroupCreatedEvent {
1352
1406
  export interface Group {
1353
1407
  id: Id;
1354
1408
  group_mode: GroupMode;
1409
+ /**
1410
+ * Channels only - whether subscribers may comment on posts.
1411
+ */
1412
+ comments_enabled?: boolean;
1413
+ comment_slow_mode?: CommentSlowMode;
1414
+ /**
1415
+ * Channels only - whether the caller gets a push for every new comment on their own posts.
1416
+ */
1417
+ notify_comments?: boolean;
1355
1418
  /**
1356
1419
  * Everyone in the group, the owner included (the subscribers of a channel).
1357
1420
  */
@@ -1568,11 +1631,15 @@ export interface ServerPostStatsEvent {
1568
1631
  message_id: Id;
1569
1632
  view_count: number;
1570
1633
  reaction_counts: ReactionCount[];
1634
+ comment_count: number;
1635
+ comments_enabled?: boolean;
1571
1636
  },
1572
1637
  ...{
1573
1638
  message_id: Id;
1574
1639
  view_count: number;
1575
1640
  reaction_counts: ReactionCount[];
1641
+ comment_count: number;
1642
+ comments_enabled?: boolean;
1576
1643
  }[]
1577
1644
  ];
1578
1645
  };
@@ -3758,6 +3758,43 @@
3758
3758
  ],
3759
3759
  "minimum": 0
3760
3760
  },
3761
+ "thread_root_id": {
3762
+ "description": "Set on a comment of a channel post (the post it belongs to); `null` for posts and other messages.",
3763
+ "oneOf": [
3764
+ {
3765
+ "$ref": "#/$defs/Id"
3766
+ },
3767
+ {
3768
+ "type": "null"
3769
+ }
3770
+ ]
3771
+ },
3772
+ "parent_id": {
3773
+ "description": "Set on a reply inside a comment thread (the top-level comment it hangs under); `null` otherwise.",
3774
+ "oneOf": [
3775
+ {
3776
+ "$ref": "#/$defs/Id"
3777
+ },
3778
+ {
3779
+ "type": "null"
3780
+ }
3781
+ ]
3782
+ },
3783
+ "comment_count": {
3784
+ "description": "Channel posts: all comments and replies. Top-level comments: their replies. `null` elsewhere. `post_stats`\nevents update it.\n",
3785
+ "type": [
3786
+ "integer",
3787
+ "null"
3788
+ ],
3789
+ "minimum": 0
3790
+ },
3791
+ "comments_enabled": {
3792
+ "description": "Channel posts only (`null` elsewhere) - whether new comments are accepted on this post.",
3793
+ "type": [
3794
+ "boolean",
3795
+ "null"
3796
+ ]
3797
+ },
3761
3798
  "read_by": {
3762
3799
  "type": "array",
3763
3800
  "items": {
@@ -4550,6 +4587,10 @@
4550
4587
  "$ref": "#/$defs/AttachmentRef"
4551
4588
  }
4552
4589
  },
4590
+ "thread_root_id": {
4591
+ "description": "Sends a comment on this channel post instead of a post. Every subscriber may comment unless comments are\noff for the channel or the post (`403`), the caller is banned from commenting (`403`), or slow mode holds\n(`429`). `reply_to` may name another comment of the same post: the comment is then a reply, listed under\nthat comment's top-level comment. Polls cannot be comments.\n",
4592
+ "$ref": "#/$defs/Id"
4593
+ },
4553
4594
  "reply_to": {
4554
4595
  "oneOf": [
4555
4596
  {
@@ -5783,6 +5824,17 @@
5783
5824
  "group_mode": {
5784
5825
  "$ref": "#/$defs/GroupMode"
5785
5826
  },
5827
+ "comments_enabled": {
5828
+ "type": "boolean",
5829
+ "description": "Channels only - whether subscribers may comment on posts."
5830
+ },
5831
+ "comment_slow_mode": {
5832
+ "$ref": "#/$defs/CommentSlowMode"
5833
+ },
5834
+ "notify_comments": {
5835
+ "type": "boolean",
5836
+ "description": "Channels only - whether the caller gets a push for every new comment on their own posts."
5837
+ },
5786
5838
  "member_count": {
5787
5839
  "type": "integer",
5788
5840
  "minimum": 0,
@@ -5894,6 +5946,53 @@
5894
5946
  "null"
5895
5947
  ],
5896
5948
  "maxLength": 500
5949
+ },
5950
+ "comments_enabled": {
5951
+ "type": "boolean",
5952
+ "description": "Channels only - whether subscribers may comment on posts."
5953
+ },
5954
+ "comment_slow_mode": {
5955
+ "$ref": "#/$defs/CommentSlowMode"
5956
+ }
5957
+ }
5958
+ },
5959
+ "CommentSlowMode": {
5960
+ "type": "integer",
5961
+ "description": "Channels only - seconds a subscriber waits between two comments; 0 is off. Owner, admins and moderators are exempt.",
5962
+ "enum": [
5963
+ 0,
5964
+ 10,
5965
+ 30,
5966
+ 60,
5967
+ 300,
5968
+ 900,
5969
+ 3600
5970
+ ]
5971
+ },
5972
+ "MessageSearchScope": {
5973
+ "type": "string",
5974
+ "description": "Inside a channel - `all` (posts and comments, the default), `posts` or `comments`.",
5975
+ "enum": [
5976
+ "all",
5977
+ "posts",
5978
+ "comments"
5979
+ ]
5980
+ },
5981
+ "SearchChatKind": {
5982
+ "type": "string",
5983
+ "description": "`channel` keeps only subscribed channels.",
5984
+ "enum": [
5985
+ "channel"
5986
+ ]
5987
+ },
5988
+ "CommentsEnabledRequest": {
5989
+ "type": "object",
5990
+ "required": [
5991
+ "enabled"
5992
+ ],
5993
+ "properties": {
5994
+ "enabled": {
5995
+ "type": "boolean"
5897
5996
  }
5898
5997
  }
5899
5998
  },
@@ -7547,6 +7646,10 @@
7547
7646
  "type": "null"
7548
7647
  }
7549
7648
  ]
7649
+ },
7650
+ "thread_root_id": {
7651
+ "description": "Comment on this channel post instead of posting (see SendMessageRequest.thread_root_id).",
7652
+ "$ref": "#/$defs/Id"
7550
7653
  }
7551
7654
  },
7552
7655
  "required": [
@@ -7586,6 +7689,10 @@
7586
7689
  "type": "null"
7587
7690
  }
7588
7691
  ]
7692
+ },
7693
+ "thread_root_id": {
7694
+ "description": "Comment on this channel post instead of posting (see SendMessageRequest.thread_root_id).",
7695
+ "$ref": "#/$defs/Id"
7589
7696
  }
7590
7697
  },
7591
7698
  "required": [
@@ -7759,6 +7866,76 @@
7759
7866
  ],
7760
7867
  "additionalProperties": false
7761
7868
  },
7869
+ "ClientThreadCloseEvent": {
7870
+ "title": "ClientThreadCloseEvent",
7871
+ "description": "You stopped looking at the comments of this channel post.",
7872
+ "type": "object",
7873
+ "properties": {
7874
+ "type": {
7875
+ "const": "thread_close"
7876
+ },
7877
+ "client_temp_id": {
7878
+ "$ref": "#/$defs/ClientTempId"
7879
+ },
7880
+ "chat_id": {
7881
+ "$ref": "#/$defs/Id"
7882
+ },
7883
+ "data": {
7884
+ "type": "object",
7885
+ "properties": {
7886
+ "message_id": {
7887
+ "$ref": "#/$defs/Id"
7888
+ }
7889
+ },
7890
+ "required": [
7891
+ "message_id"
7892
+ ],
7893
+ "additionalProperties": false
7894
+ }
7895
+ },
7896
+ "required": [
7897
+ "type",
7898
+ "client_temp_id",
7899
+ "chat_id",
7900
+ "data"
7901
+ ],
7902
+ "additionalProperties": false
7903
+ },
7904
+ "ClientThreadOpenEvent": {
7905
+ "title": "ClientThreadOpenEvent",
7906
+ "description": "You are looking at the comments of this channel post: new, edited and deleted comments are sent to you. Send it again at least every 2 minutes while the thread stays open.",
7907
+ "type": "object",
7908
+ "properties": {
7909
+ "type": {
7910
+ "const": "thread_open"
7911
+ },
7912
+ "client_temp_id": {
7913
+ "$ref": "#/$defs/ClientTempId"
7914
+ },
7915
+ "chat_id": {
7916
+ "$ref": "#/$defs/Id"
7917
+ },
7918
+ "data": {
7919
+ "type": "object",
7920
+ "properties": {
7921
+ "message_id": {
7922
+ "$ref": "#/$defs/Id"
7923
+ }
7924
+ },
7925
+ "required": [
7926
+ "message_id"
7927
+ ],
7928
+ "additionalProperties": false
7929
+ }
7930
+ },
7931
+ "required": [
7932
+ "type",
7933
+ "client_temp_id",
7934
+ "chat_id",
7935
+ "data"
7936
+ ],
7937
+ "additionalProperties": false
7938
+ },
7762
7939
  "ClientTypingEvent": {
7763
7940
  "title": "ClientTypingEvent",
7764
7941
  "description": "Tell the chat that you are (not) typing, recording a voice message, choosing a sticker or sending a photo, video or file. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.",
@@ -8739,12 +8916,20 @@
8739
8916
  "items": {
8740
8917
  "$ref": "#/$defs/ReactionCount"
8741
8918
  }
8919
+ },
8920
+ "comment_count": {
8921
+ "type": "integer",
8922
+ "minimum": 0
8923
+ },
8924
+ "comments_enabled": {
8925
+ "type": "boolean"
8742
8926
  }
8743
8927
  },
8744
8928
  "required": [
8745
8929
  "message_id",
8746
8930
  "view_count",
8747
- "reaction_counts"
8931
+ "reaction_counts",
8932
+ "comment_count"
8748
8933
  ]
8749
8934
  }
8750
8935
  }
@@ -9278,6 +9463,12 @@
9278
9463
  {
9279
9464
  "$ref": "#/$defs/ClientResendEvent"
9280
9465
  },
9466
+ {
9467
+ "$ref": "#/$defs/ClientThreadCloseEvent"
9468
+ },
9469
+ {
9470
+ "$ref": "#/$defs/ClientThreadOpenEvent"
9471
+ },
9281
9472
  {
9282
9473
  "$ref": "#/$defs/ClientTypingEvent"
9283
9474
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myronsi/messenger-api",
3
- "version": "2.1.0-alpha.58.next.204",
3
+ "version": "2.1.0-alpha.59.next.206",
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": {