@myronsi/messenger-api 2.1.0-alpha.41 → 2.1.0-alpha.42
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 +137 -3
- package/dist/schema.d.ts +217 -3
- package/dist/ws-docs.json +15 -1
- package/dist/ws-events.d.ts +49 -3
- package/dist/ws-events.schema.json +158 -2
- 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.42
|
|
6
|
+
|
|
7
|
+
- Pinned messages: `PUT /chats/{chat_id}/messages/{message_id}/pin` (`PinMessageRequest` with `PinScope` `me` or
|
|
8
|
+
`everyone`, returns `PinnedMessage`), `DELETE /chats/{chat_id}/messages/{message_id}/pin?scope=` and
|
|
9
|
+
`GET /chats/{chat_id}/pins` (`PinnedMessagePage`). At most 500 pins for everyone per chat and 500 own pins per member
|
|
10
|
+
and chat (`409` `limit_reached`).
|
|
11
|
+
- `Chat.pinned_message_count`.
|
|
12
|
+
- `SystemEventKind` gains `message_pinned` and `message_unpinned`; `SystemEvent` gains `message_id`, `snippet` and
|
|
13
|
+
`message_type`.
|
|
14
|
+
- WebSocket server event `pin_update`.
|
|
15
|
+
|
|
5
16
|
## 2.1.0-alpha.41
|
|
6
17
|
|
|
7
18
|
- Public cards without an account (tag `public`, `security: []`, rate limited per IP, `X-Robots-Tag: noindex`):
|
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.42. Do not edit. */
|
|
2
|
+
export declare const API_VERSION: "2.1.0-alpha.42";
|
|
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.42";
|
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.42
|
|
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
|
|
@@ -2240,6 +2240,94 @@ paths:
|
|
|
2240
2240
|
"204":
|
|
2241
2241
|
description: Withdrawn
|
|
2242
2242
|
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2243
|
+
/chats/{chat_id}/messages/{message_id}/pin:
|
|
2244
|
+
parameters:
|
|
2245
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
2246
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
2247
|
+
- $ref: "#/components/parameters/ChatId"
|
|
2248
|
+
- $ref: "#/components/parameters/MessageId"
|
|
2249
|
+
put:
|
|
2250
|
+
tags: [messages]
|
|
2251
|
+
operationId: pinMessage
|
|
2252
|
+
summary: Pin a message
|
|
2253
|
+
description: |
|
|
2254
|
+
`me` pins the message only for the caller. `everyone` pins it for every member: in a direct chat either
|
|
2255
|
+
user may, in a group only a moderator, admin or owner (`403` otherwise). Saved Messages, a chat in the
|
|
2256
|
+
caller's Requests folder and a direct chat with a block allow only `me` (`403` for `everyone`). System and
|
|
2257
|
+
call messages cannot be pinned (`422`); a message the caller cannot see is `404`. A chat holds at most 500
|
|
2258
|
+
pins for everyone, and each member at most 500 own pins in it (`409` `limit_reached`).
|
|
2259
|
+
|
|
2260
|
+
Pinning a pinned message changes nothing, except that `me` shows a pin for everyone again that the caller
|
|
2261
|
+
hid. Pinning for everyone a message the caller pinned for themselves keeps their own pin underneath: it
|
|
2262
|
+
shows again when the pin for everyone is removed. Pinning or unpinning for everyone posts a system message
|
|
2263
|
+
(`message_pinned`, `message_unpinned`) without a push notification. Every change sends `pin_update`.
|
|
2264
|
+
requestBody:
|
|
2265
|
+
required: true
|
|
2266
|
+
content:
|
|
2267
|
+
application/json:
|
|
2268
|
+
schema: { $ref: "#/components/schemas/PinMessageRequest" }
|
|
2269
|
+
responses:
|
|
2270
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
2271
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
2272
|
+
"200":
|
|
2273
|
+
description: The pin as the caller sees it
|
|
2274
|
+
content:
|
|
2275
|
+
application/json:
|
|
2276
|
+
schema: { $ref: "#/components/schemas/PinnedMessage" }
|
|
2277
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2278
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
2279
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
2280
|
+
"409": { $ref: "#/components/responses/Conflict" }
|
|
2281
|
+
"422": { $ref: "#/components/responses/ValidationFailed" }
|
|
2282
|
+
delete:
|
|
2283
|
+
tags: [messages]
|
|
2284
|
+
operationId: unpinMessage
|
|
2285
|
+
summary: Unpin a message
|
|
2286
|
+
description: |
|
|
2287
|
+
`me` removes the caller's own pin, or hides a pin for everyone only for the caller (it stays pinned for the
|
|
2288
|
+
others). `everyone` removes the pin for everyone: in a direct chat either user may; in a group a moderator,
|
|
2289
|
+
admin or owner whose role is at least the role the pinner has now (owner > admin > moderator; a pinner who
|
|
2290
|
+
left or is a member counts as member), otherwise `403`. `PinnedMessage.can_unpin_for_everyone` tells the
|
|
2291
|
+
client in advance. Unpinning a message that is not pinned changes nothing.
|
|
2292
|
+
parameters:
|
|
2293
|
+
- name: scope
|
|
2294
|
+
in: query
|
|
2295
|
+
required: true
|
|
2296
|
+
schema: { $ref: "#/components/schemas/PinScope" }
|
|
2297
|
+
responses:
|
|
2298
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
2299
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
2300
|
+
"204":
|
|
2301
|
+
description: Unpinned
|
|
2302
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2303
|
+
"403": { $ref: "#/components/responses/Forbidden" }
|
|
2304
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
2305
|
+
/chats/{chat_id}/pins:
|
|
2306
|
+
parameters:
|
|
2307
|
+
- $ref: "#/components/parameters/ClientVersion"
|
|
2308
|
+
- $ref: "#/components/parameters/ClientApiVersion"
|
|
2309
|
+
- $ref: "#/components/parameters/ChatId"
|
|
2310
|
+
get:
|
|
2311
|
+
tags: [messages]
|
|
2312
|
+
operationId: listPinnedMessages
|
|
2313
|
+
summary: The pinned messages of a chat as the caller sees them
|
|
2314
|
+
description: |
|
|
2315
|
+
Pins for everyone the caller did not hide, and the caller's own pins, newest pin first. A message pinned
|
|
2316
|
+
both ways appears once, as `everyone`. Messages the caller cannot see (deleted, deleted for them, cleared
|
|
2317
|
+
from their history) are left out. `Chat.pinned_message_count` counts the same pins.
|
|
2318
|
+
parameters:
|
|
2319
|
+
- $ref: "#/components/parameters/Limit"
|
|
2320
|
+
- $ref: "#/components/parameters/After"
|
|
2321
|
+
responses:
|
|
2322
|
+
"426": { $ref: "#/components/responses/ClientOutdated" }
|
|
2323
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
2324
|
+
"200":
|
|
2325
|
+
description: Pinned messages, newest pin first
|
|
2326
|
+
content:
|
|
2327
|
+
application/json:
|
|
2328
|
+
schema: { $ref: "#/components/schemas/PinnedMessagePage" }
|
|
2329
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
2330
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
2243
2331
|
/chats/{chat_id}/messages/forward:
|
|
2244
2332
|
parameters:
|
|
2245
2333
|
- $ref: "#/components/parameters/ClientVersion"
|
|
@@ -7680,14 +7768,14 @@ components:
|
|
|
7680
7768
|
height: { type: [integer, "null"], minimum: 1 }
|
|
7681
7769
|
SystemEventKind:
|
|
7682
7770
|
type: string
|
|
7683
|
-
enum: [group_created, member_added, member_joined, member_removed, member_left, call]
|
|
7771
|
+
enum: [group_created, member_added, member_joined, member_removed, member_left, call, message_pinned, message_unpinned]
|
|
7684
7772
|
SystemEvent:
|
|
7685
7773
|
type: object
|
|
7686
7774
|
description: |
|
|
7687
7775
|
What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
7688
7776
|
are the display names at the time of the event. `target` fields are set for `member_added` and
|
|
7689
7777
|
`member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
|
|
7690
|
-
initiator.
|
|
7778
|
+
initiator. `message_id` and `snippet` are set for `message_pinned` and `message_unpinned`.
|
|
7691
7779
|
required: [kind, actor_id, actor_name]
|
|
7692
7780
|
properties:
|
|
7693
7781
|
kind: { $ref: "#/components/schemas/SystemEventKind" }
|
|
@@ -7699,6 +7787,16 @@ components:
|
|
|
7699
7787
|
target_id: { $ref: "#/components/schemas/Id" }
|
|
7700
7788
|
target_name: { type: string }
|
|
7701
7789
|
call: { $ref: "#/components/schemas/CallSummary" }
|
|
7790
|
+
message_id:
|
|
7791
|
+
description: The pinned or unpinned message.
|
|
7792
|
+
allOf: [{ $ref: "#/components/schemas/Id" }]
|
|
7793
|
+
snippet:
|
|
7794
|
+
type: string
|
|
7795
|
+
maxLength: 64
|
|
7796
|
+
description: |
|
|
7797
|
+
Start of the pinned message's text at the time of the event (at most 60 characters plus `…`); empty for a
|
|
7798
|
+
message without text, which clients name by its `message_type`.
|
|
7799
|
+
message_type: { $ref: "#/components/schemas/MessageType" }
|
|
7702
7800
|
MessagePage:
|
|
7703
7801
|
type: object
|
|
7704
7802
|
required: [items, next_cursor, prev_cursor]
|
|
@@ -7940,6 +8038,7 @@ components:
|
|
|
7940
8038
|
- first_unread_message_id
|
|
7941
8039
|
- last_read_message_id
|
|
7942
8040
|
- last_message
|
|
8041
|
+
- pinned_message_count
|
|
7943
8042
|
- created_at
|
|
7944
8043
|
properties:
|
|
7945
8044
|
id: { $ref: "#/components/schemas/Id" }
|
|
@@ -7994,6 +8093,10 @@ components:
|
|
|
7994
8093
|
oneOf:
|
|
7995
8094
|
- $ref: "#/components/schemas/GroupRole"
|
|
7996
8095
|
- type: "null"
|
|
8096
|
+
pinned_message_count:
|
|
8097
|
+
type: integer
|
|
8098
|
+
minimum: 0
|
|
8099
|
+
description: Pinned messages the caller sees (`GET /chats/{chat_id}/pins`); clients show the pinned bar above 0.
|
|
7997
8100
|
created_at: { $ref: "#/components/schemas/Timestamp" }
|
|
7998
8101
|
ChatRequestCount:
|
|
7999
8102
|
type: object
|
|
@@ -8024,6 +8127,37 @@ components:
|
|
|
8024
8127
|
maxItems: 10
|
|
8025
8128
|
uniqueItems: true
|
|
8026
8129
|
items: { $ref: "#/components/schemas/Id" }
|
|
8130
|
+
PinScope:
|
|
8131
|
+
type: string
|
|
8132
|
+
description: "`me`: only for the caller. `everyone`: for every member of the chat."
|
|
8133
|
+
enum: [me, everyone]
|
|
8134
|
+
PinMessageRequest:
|
|
8135
|
+
type: object
|
|
8136
|
+
required: [scope]
|
|
8137
|
+
properties:
|
|
8138
|
+
scope: { $ref: "#/components/schemas/PinScope" }
|
|
8139
|
+
PinnedMessage:
|
|
8140
|
+
type: object
|
|
8141
|
+
required: [message, scope, pinned_by, pinned_at, can_unpin_for_everyone]
|
|
8142
|
+
properties:
|
|
8143
|
+
message: { $ref: "#/components/schemas/Message" }
|
|
8144
|
+
scope: { $ref: "#/components/schemas/PinScope" }
|
|
8145
|
+
pinned_by:
|
|
8146
|
+
description: Who pinned it; the caller for `me`.
|
|
8147
|
+
allOf: [{ $ref: "#/components/schemas/Id" }]
|
|
8148
|
+
pinned_at: { $ref: "#/components/schemas/Timestamp" }
|
|
8149
|
+
can_unpin_for_everyone:
|
|
8150
|
+
type: boolean
|
|
8151
|
+
description: Whether `DELETE …/pin?scope=everyone` is allowed for the caller; always `false` for `me`.
|
|
8152
|
+
PinnedMessagePage:
|
|
8153
|
+
type: object
|
|
8154
|
+
required: [items, next_cursor]
|
|
8155
|
+
properties:
|
|
8156
|
+
items:
|
|
8157
|
+
type: array
|
|
8158
|
+
description: Newest pin first
|
|
8159
|
+
items: { $ref: "#/components/schemas/PinnedMessage" }
|
|
8160
|
+
next_cursor: { $ref: "#/components/schemas/Cursor" }
|
|
8027
8161
|
CreateChatRequest:
|
|
8028
8162
|
type: object
|
|
8029
8163
|
required: [user_id]
|
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.42. Do not edit. */
|
|
2
2
|
export interface paths {
|
|
3
3
|
"/meta": {
|
|
4
4
|
parameters: {
|
|
@@ -1918,6 +1918,80 @@ export interface paths {
|
|
|
1918
1918
|
patch?: never;
|
|
1919
1919
|
trace?: never;
|
|
1920
1920
|
};
|
|
1921
|
+
"/chats/{chat_id}/messages/{message_id}/pin": {
|
|
1922
|
+
parameters: {
|
|
1923
|
+
query?: never;
|
|
1924
|
+
header?: {
|
|
1925
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
1926
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
1927
|
+
/** @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`). */
|
|
1928
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
1929
|
+
};
|
|
1930
|
+
path: {
|
|
1931
|
+
chat_id: components["parameters"]["ChatId"];
|
|
1932
|
+
message_id: components["parameters"]["MessageId"];
|
|
1933
|
+
};
|
|
1934
|
+
cookie?: never;
|
|
1935
|
+
};
|
|
1936
|
+
get?: never;
|
|
1937
|
+
/**
|
|
1938
|
+
* Pin a message
|
|
1939
|
+
* @description `me` pins the message only for the caller. `everyone` pins it for every member: in a direct chat either
|
|
1940
|
+
* user may, in a group only a moderator, admin or owner (`403` otherwise). Saved Messages, a chat in the
|
|
1941
|
+
* caller's Requests folder and a direct chat with a block allow only `me` (`403` for `everyone`). System and
|
|
1942
|
+
* call messages cannot be pinned (`422`); a message the caller cannot see is `404`. A chat holds at most 500
|
|
1943
|
+
* pins for everyone, and each member at most 500 own pins in it (`409` `limit_reached`).
|
|
1944
|
+
*
|
|
1945
|
+
* Pinning a pinned message changes nothing, except that `me` shows a pin for everyone again that the caller
|
|
1946
|
+
* hid. Pinning for everyone a message the caller pinned for themselves keeps their own pin underneath: it
|
|
1947
|
+
* shows again when the pin for everyone is removed. Pinning or unpinning for everyone posts a system message
|
|
1948
|
+
* (`message_pinned`, `message_unpinned`) without a push notification. Every change sends `pin_update`.
|
|
1949
|
+
*/
|
|
1950
|
+
put: operations["pinMessage"];
|
|
1951
|
+
post?: never;
|
|
1952
|
+
/**
|
|
1953
|
+
* Unpin a message
|
|
1954
|
+
* @description `me` removes the caller's own pin, or hides a pin for everyone only for the caller (it stays pinned for the
|
|
1955
|
+
* others). `everyone` removes the pin for everyone: in a direct chat either user may; in a group a moderator,
|
|
1956
|
+
* admin or owner whose role is at least the role the pinner has now (owner > admin > moderator; a pinner who
|
|
1957
|
+
* left or is a member counts as member), otherwise `403`. `PinnedMessage.can_unpin_for_everyone` tells the
|
|
1958
|
+
* client in advance. Unpinning a message that is not pinned changes nothing.
|
|
1959
|
+
*/
|
|
1960
|
+
delete: operations["unpinMessage"];
|
|
1961
|
+
options?: never;
|
|
1962
|
+
head?: never;
|
|
1963
|
+
patch?: never;
|
|
1964
|
+
trace?: never;
|
|
1965
|
+
};
|
|
1966
|
+
"/chats/{chat_id}/pins": {
|
|
1967
|
+
parameters: {
|
|
1968
|
+
query?: never;
|
|
1969
|
+
header?: {
|
|
1970
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
1971
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
1972
|
+
/** @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`). */
|
|
1973
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
1974
|
+
};
|
|
1975
|
+
path: {
|
|
1976
|
+
chat_id: components["parameters"]["ChatId"];
|
|
1977
|
+
};
|
|
1978
|
+
cookie?: never;
|
|
1979
|
+
};
|
|
1980
|
+
/**
|
|
1981
|
+
* The pinned messages of a chat as the caller sees them
|
|
1982
|
+
* @description Pins for everyone the caller did not hide, and the caller's own pins, newest pin first. A message pinned
|
|
1983
|
+
* both ways appears once, as `everyone`. Messages the caller cannot see (deleted, deleted for them, cleared
|
|
1984
|
+
* from their history) are left out. `Chat.pinned_message_count` counts the same pins.
|
|
1985
|
+
*/
|
|
1986
|
+
get: operations["listPinnedMessages"];
|
|
1987
|
+
put?: never;
|
|
1988
|
+
post?: never;
|
|
1989
|
+
delete?: never;
|
|
1990
|
+
options?: never;
|
|
1991
|
+
head?: never;
|
|
1992
|
+
patch?: never;
|
|
1993
|
+
trace?: never;
|
|
1994
|
+
};
|
|
1921
1995
|
"/chats/{chat_id}/messages/forward": {
|
|
1922
1996
|
parameters: {
|
|
1923
1997
|
query?: never;
|
|
@@ -5528,12 +5602,12 @@ export interface components {
|
|
|
5528
5602
|
height: number | null;
|
|
5529
5603
|
};
|
|
5530
5604
|
/** @enum {string} */
|
|
5531
|
-
SystemEventKind: "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left" | "call";
|
|
5605
|
+
SystemEventKind: "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left" | "call" | "message_pinned" | "message_unpinned";
|
|
5532
5606
|
/**
|
|
5533
5607
|
* @description What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
5534
5608
|
* are the display names at the time of the event. `target` fields are set for `member_added` and
|
|
5535
5609
|
* `member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
|
|
5536
|
-
* initiator.
|
|
5610
|
+
* initiator. `message_id` and `snippet` are set for `message_pinned` and `message_unpinned`.
|
|
5537
5611
|
*/
|
|
5538
5612
|
SystemEvent: {
|
|
5539
5613
|
kind: components["schemas"]["SystemEventKind"];
|
|
@@ -5542,6 +5616,14 @@ export interface components {
|
|
|
5542
5616
|
target_id?: components["schemas"]["Id"];
|
|
5543
5617
|
target_name?: string;
|
|
5544
5618
|
call?: components["schemas"]["CallSummary"];
|
|
5619
|
+
/** @description The pinned or unpinned message. */
|
|
5620
|
+
message_id?: components["schemas"]["Id"];
|
|
5621
|
+
/**
|
|
5622
|
+
* @description Start of the pinned message's text at the time of the event (at most 60 characters plus `…`); empty for a
|
|
5623
|
+
* message without text, which clients name by its `message_type`.
|
|
5624
|
+
*/
|
|
5625
|
+
snippet?: string;
|
|
5626
|
+
message_type?: components["schemas"]["MessageType"];
|
|
5545
5627
|
};
|
|
5546
5628
|
MessagePage: {
|
|
5547
5629
|
/** @description Oldest to newest */
|
|
@@ -5680,6 +5762,8 @@ export interface components {
|
|
|
5680
5762
|
last_message: components["schemas"]["Message"] | null;
|
|
5681
5763
|
/** @description Only for groups. */
|
|
5682
5764
|
my_role?: components["schemas"]["GroupRole"] | null;
|
|
5765
|
+
/** @description Pinned messages the caller sees (`GET /chats/{chat_id}/pins`); clients show the pinned bar above 0. */
|
|
5766
|
+
pinned_message_count: number;
|
|
5683
5767
|
created_at: components["schemas"]["Timestamp"];
|
|
5684
5768
|
};
|
|
5685
5769
|
ChatRequestCount: {
|
|
@@ -5696,6 +5780,28 @@ export interface components {
|
|
|
5696
5780
|
PinOrderRequest: {
|
|
5697
5781
|
chat_ids: components["schemas"]["Id"][];
|
|
5698
5782
|
};
|
|
5783
|
+
/**
|
|
5784
|
+
* @description `me`: only for the caller. `everyone`: for every member of the chat.
|
|
5785
|
+
* @enum {string}
|
|
5786
|
+
*/
|
|
5787
|
+
PinScope: "me" | "everyone";
|
|
5788
|
+
PinMessageRequest: {
|
|
5789
|
+
scope: components["schemas"]["PinScope"];
|
|
5790
|
+
};
|
|
5791
|
+
PinnedMessage: {
|
|
5792
|
+
message: components["schemas"]["Message"];
|
|
5793
|
+
scope: components["schemas"]["PinScope"];
|
|
5794
|
+
/** @description Who pinned it; the caller for `me`. */
|
|
5795
|
+
pinned_by: components["schemas"]["Id"];
|
|
5796
|
+
pinned_at: components["schemas"]["Timestamp"];
|
|
5797
|
+
/** @description Whether `DELETE …/pin?scope=everyone` is allowed for the caller; always `false` for `me`. */
|
|
5798
|
+
can_unpin_for_everyone: boolean;
|
|
5799
|
+
};
|
|
5800
|
+
PinnedMessagePage: {
|
|
5801
|
+
/** @description Newest pin first */
|
|
5802
|
+
items: components["schemas"]["PinnedMessage"][];
|
|
5803
|
+
next_cursor: components["schemas"]["Cursor"];
|
|
5804
|
+
};
|
|
5699
5805
|
CreateChatRequest: {
|
|
5700
5806
|
user_id: components["schemas"]["Id"];
|
|
5701
5807
|
initial_message?: string | null;
|
|
@@ -9366,6 +9472,114 @@ export interface operations {
|
|
|
9366
9472
|
426: components["responses"]["ClientOutdated"];
|
|
9367
9473
|
};
|
|
9368
9474
|
};
|
|
9475
|
+
pinMessage: {
|
|
9476
|
+
parameters: {
|
|
9477
|
+
query?: never;
|
|
9478
|
+
header?: {
|
|
9479
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
9480
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
9481
|
+
/** @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`). */
|
|
9482
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
9483
|
+
};
|
|
9484
|
+
path: {
|
|
9485
|
+
chat_id: components["parameters"]["ChatId"];
|
|
9486
|
+
message_id: components["parameters"]["MessageId"];
|
|
9487
|
+
};
|
|
9488
|
+
cookie?: never;
|
|
9489
|
+
};
|
|
9490
|
+
requestBody: {
|
|
9491
|
+
content: {
|
|
9492
|
+
"application/json": components["schemas"]["PinMessageRequest"];
|
|
9493
|
+
};
|
|
9494
|
+
};
|
|
9495
|
+
responses: {
|
|
9496
|
+
/** @description The pin as the caller sees it */
|
|
9497
|
+
200: {
|
|
9498
|
+
headers: {
|
|
9499
|
+
[name: string]: unknown;
|
|
9500
|
+
};
|
|
9501
|
+
content: {
|
|
9502
|
+
"application/json": components["schemas"]["PinnedMessage"];
|
|
9503
|
+
};
|
|
9504
|
+
};
|
|
9505
|
+
400: components["responses"]["BadRequest"];
|
|
9506
|
+
401: components["responses"]["Unauthorized"];
|
|
9507
|
+
403: components["responses"]["Forbidden"];
|
|
9508
|
+
404: components["responses"]["NotFound"];
|
|
9509
|
+
409: components["responses"]["Conflict"];
|
|
9510
|
+
422: components["responses"]["ValidationFailed"];
|
|
9511
|
+
426: components["responses"]["ClientOutdated"];
|
|
9512
|
+
};
|
|
9513
|
+
};
|
|
9514
|
+
unpinMessage: {
|
|
9515
|
+
parameters: {
|
|
9516
|
+
query: {
|
|
9517
|
+
scope: components["schemas"]["PinScope"];
|
|
9518
|
+
};
|
|
9519
|
+
header?: {
|
|
9520
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
9521
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
9522
|
+
/** @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`). */
|
|
9523
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
9524
|
+
};
|
|
9525
|
+
path: {
|
|
9526
|
+
chat_id: components["parameters"]["ChatId"];
|
|
9527
|
+
message_id: components["parameters"]["MessageId"];
|
|
9528
|
+
};
|
|
9529
|
+
cookie?: never;
|
|
9530
|
+
};
|
|
9531
|
+
requestBody?: never;
|
|
9532
|
+
responses: {
|
|
9533
|
+
/** @description Unpinned */
|
|
9534
|
+
204: {
|
|
9535
|
+
headers: {
|
|
9536
|
+
[name: string]: unknown;
|
|
9537
|
+
};
|
|
9538
|
+
content?: never;
|
|
9539
|
+
};
|
|
9540
|
+
400: components["responses"]["BadRequest"];
|
|
9541
|
+
401: components["responses"]["Unauthorized"];
|
|
9542
|
+
403: components["responses"]["Forbidden"];
|
|
9543
|
+
404: components["responses"]["NotFound"];
|
|
9544
|
+
426: components["responses"]["ClientOutdated"];
|
|
9545
|
+
};
|
|
9546
|
+
};
|
|
9547
|
+
listPinnedMessages: {
|
|
9548
|
+
parameters: {
|
|
9549
|
+
query?: {
|
|
9550
|
+
/** @description Page size */
|
|
9551
|
+
limit?: components["parameters"]["Limit"];
|
|
9552
|
+
/** @description Opaque `next_cursor` of the previous page */
|
|
9553
|
+
after?: components["parameters"]["After"];
|
|
9554
|
+
};
|
|
9555
|
+
header?: {
|
|
9556
|
+
/** @description Version of the client app, for logs and the per-client metric. */
|
|
9557
|
+
"X-Client-Version"?: components["parameters"]["ClientVersion"];
|
|
9558
|
+
/** @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`). */
|
|
9559
|
+
"X-Client-Api-Version"?: components["parameters"]["ClientApiVersion"];
|
|
9560
|
+
};
|
|
9561
|
+
path: {
|
|
9562
|
+
chat_id: components["parameters"]["ChatId"];
|
|
9563
|
+
};
|
|
9564
|
+
cookie?: never;
|
|
9565
|
+
};
|
|
9566
|
+
requestBody?: never;
|
|
9567
|
+
responses: {
|
|
9568
|
+
/** @description Pinned messages, newest pin first */
|
|
9569
|
+
200: {
|
|
9570
|
+
headers: {
|
|
9571
|
+
[name: string]: unknown;
|
|
9572
|
+
};
|
|
9573
|
+
content: {
|
|
9574
|
+
"application/json": components["schemas"]["PinnedMessagePage"];
|
|
9575
|
+
};
|
|
9576
|
+
};
|
|
9577
|
+
400: components["responses"]["BadRequest"];
|
|
9578
|
+
401: components["responses"]["Unauthorized"];
|
|
9579
|
+
404: components["responses"]["NotFound"];
|
|
9580
|
+
426: components["responses"]["ClientOutdated"];
|
|
9581
|
+
};
|
|
9582
|
+
};
|
|
9369
9583
|
forwardMessages: {
|
|
9370
9584
|
parameters: {
|
|
9371
9585
|
query?: never;
|
package/dist/ws-docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`, and `data.field` when one setting or field caused it (for example `voice_video_messages`). `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted; `delete` with `removed_by_moderation` when moderation removed it (the sender's copy also carries `moderation_reason`) |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\r\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\r\n| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\n| `attachment_updated` | An optimized copy of an attachment you can see is ready (or failed): replace it in your messages |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
2
|
+
"markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`, and `data.field` when one setting or field caused it (for example `voice_video_messages`). `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted; `delete` with `removed_by_moderation` when moderation removed it (the sender's copy also carries `moderation_reason`) |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing, recording a voice message, choosing a sticker or sending a photo, video or file (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\n| `history_cleared` | Messages up to `before_message_id` were cleared for you (`scope: me`) or everyone |\r\n| `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 |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `account_status` | Your account status changed (`AccountStatus`); only your own sessions get it |\r\n| `report_outcome` | The moderation team reviewed something you reported (`ReportOutcome`); only your own sessions get it |\r\n| `user_updated` | A user you share a chat with changed their profile (`profile_version`) |\n| `attachment_updated` | An optimized copy of an attachment you can see is ready (or failed): replace it in your messages |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
|
|
3
3
|
"examples": {
|
|
4
4
|
"client/delete.json": {
|
|
5
5
|
"type": "delete",
|
|
@@ -253,6 +253,7 @@
|
|
|
253
253
|
"is_request": false,
|
|
254
254
|
"unread_count": 1,
|
|
255
255
|
"unread_mentions_count": 0,
|
|
256
|
+
"pinned_message_count": 0,
|
|
256
257
|
"first_unread_message_id": "7217400317439950001",
|
|
257
258
|
"last_read_message_id": null,
|
|
258
259
|
"last_message": {
|
|
@@ -327,6 +328,7 @@
|
|
|
327
328
|
"is_request": false,
|
|
328
329
|
"unread_count": 1,
|
|
329
330
|
"unread_mentions_count": 0,
|
|
331
|
+
"pinned_message_count": 0,
|
|
330
332
|
"first_unread_message_id": "7217400317439950001",
|
|
331
333
|
"last_read_message_id": null,
|
|
332
334
|
"last_message": {
|
|
@@ -555,6 +557,18 @@
|
|
|
555
557
|
}
|
|
556
558
|
}
|
|
557
559
|
},
|
|
560
|
+
"server/pin_update.json": {
|
|
561
|
+
"type": "pin_update",
|
|
562
|
+
"event_id": "7217400317439950012",
|
|
563
|
+
"chat_id": "42",
|
|
564
|
+
"data": {
|
|
565
|
+
"message_id": "7217400317439950002",
|
|
566
|
+
"action": "pinned",
|
|
567
|
+
"scope": "everyone",
|
|
568
|
+
"actor_id": "7",
|
|
569
|
+
"at": "2026-11-21T10:15:00Z"
|
|
570
|
+
}
|
|
571
|
+
},
|
|
558
572
|
"server/presence.json": {
|
|
559
573
|
"type": "presence",
|
|
560
574
|
"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.42. Do not edit. */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Any WebSocket event, in either direction.
|
|
@@ -49,6 +49,7 @@ export type ServerEvent =
|
|
|
49
49
|
| ServerHelloEvent
|
|
50
50
|
| ServerHistoryClearedEvent
|
|
51
51
|
| ServerMessageEvent
|
|
52
|
+
| ServerPinUpdateEvent
|
|
52
53
|
| ServerPresenceEvent
|
|
53
54
|
| ServerReactionAddEvent
|
|
54
55
|
| ServerReactionRemoveEvent
|
|
@@ -137,7 +138,14 @@ export type ChatType = "direct" | "group";
|
|
|
137
138
|
export type MessageType = "text" | "file" | "voice" | "system" | "sticker";
|
|
138
139
|
export type StickerPackSlug = string;
|
|
139
140
|
export type SystemEventKind =
|
|
140
|
-
|
|
141
|
+
| "group_created"
|
|
142
|
+
| "member_added"
|
|
143
|
+
| "member_joined"
|
|
144
|
+
| "member_removed"
|
|
145
|
+
| "member_left"
|
|
146
|
+
| "call"
|
|
147
|
+
| "message_pinned"
|
|
148
|
+
| "message_unpinned";
|
|
141
149
|
/**
|
|
142
150
|
* A moderator may delete other members' messages; owners and admins also manage the group.
|
|
143
151
|
*/
|
|
@@ -184,6 +192,10 @@ export type ErrorCode =
|
|
|
184
192
|
*
|
|
185
193
|
*/
|
|
186
194
|
export type PublicName = string;
|
|
195
|
+
/**
|
|
196
|
+
* `me`: only for the caller. `everyone`: for every member of the chat.
|
|
197
|
+
*/
|
|
198
|
+
export type PinScope = "me" | "everyone";
|
|
187
199
|
/**
|
|
188
200
|
* What was reported. Unknown values must be shown without the subject.
|
|
189
201
|
*/
|
|
@@ -762,6 +774,10 @@ export interface Chat {
|
|
|
762
774
|
* Only for groups.
|
|
763
775
|
*/
|
|
764
776
|
my_role?: GroupRole | null;
|
|
777
|
+
/**
|
|
778
|
+
* Pinned messages the caller sees (`GET /chats/{chat_id}/pins`); clients show the pinned bar above 0.
|
|
779
|
+
*/
|
|
780
|
+
pinned_message_count: number;
|
|
765
781
|
created_at: Timestamp;
|
|
766
782
|
}
|
|
767
783
|
export interface Message {
|
|
@@ -939,7 +955,7 @@ export interface ModerationRemovalReason {
|
|
|
939
955
|
* What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
940
956
|
* are the display names at the time of the event. `target` fields are set for `member_added` and
|
|
941
957
|
* `member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
|
|
942
|
-
* initiator.
|
|
958
|
+
* initiator. `message_id` and `snippet` are set for `message_pinned` and `message_unpinned`.
|
|
943
959
|
*
|
|
944
960
|
*/
|
|
945
961
|
export interface SystemEvent {
|
|
@@ -949,6 +965,17 @@ export interface SystemEvent {
|
|
|
949
965
|
target_id?: Id;
|
|
950
966
|
target_name?: string;
|
|
951
967
|
call?: CallSummary;
|
|
968
|
+
/**
|
|
969
|
+
* The pinned or unpinned message.
|
|
970
|
+
*/
|
|
971
|
+
message_id?: Id;
|
|
972
|
+
/**
|
|
973
|
+
* Start of the pinned message's text at the time of the event (at most 60 characters plus `…`); empty for a
|
|
974
|
+
* message without text, which clients name by its `message_type`.
|
|
975
|
+
*
|
|
976
|
+
*/
|
|
977
|
+
snippet?: string;
|
|
978
|
+
message_type?: MessageType;
|
|
952
979
|
}
|
|
953
980
|
/**
|
|
954
981
|
* The call a `call` system message records.
|
|
@@ -1138,6 +1165,25 @@ export interface ServerMessageEvent {
|
|
|
1138
1165
|
message: Message;
|
|
1139
1166
|
};
|
|
1140
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* A message was pinned or unpinned. Scope everyone goes to every member; scope me (an own pin, or a pin for everyone hidden or shown again for you) only to your own sessions. Load GET /chats/{chat_id}/pins again, or apply the change: pinned adds the message to your pins, unpinned removes it. For scope everyone, unpinned may leave your own pin of the message, so reload in that case.
|
|
1170
|
+
*/
|
|
1171
|
+
export interface ServerPinUpdateEvent {
|
|
1172
|
+
type: "pin_update";
|
|
1173
|
+
event_id: Id;
|
|
1174
|
+
chat_id: Id;
|
|
1175
|
+
data: {
|
|
1176
|
+
message_id: Id;
|
|
1177
|
+
action: "pinned" | "unpinned";
|
|
1178
|
+
scope: PinScope;
|
|
1179
|
+
actor_id: Id;
|
|
1180
|
+
at: Timestamp;
|
|
1181
|
+
/**
|
|
1182
|
+
* Chat.pinned_message_count for the recipient after the change.
|
|
1183
|
+
*/
|
|
1184
|
+
pinned_message_count?: number;
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1141
1187
|
/**
|
|
1142
1188
|
* A user came online or went offline, as far as their privacy settings allow.
|
|
1143
1189
|
*/
|
|
@@ -3262,12 +3262,14 @@
|
|
|
3262
3262
|
"member_joined",
|
|
3263
3263
|
"member_removed",
|
|
3264
3264
|
"member_left",
|
|
3265
|
-
"call"
|
|
3265
|
+
"call",
|
|
3266
|
+
"message_pinned",
|
|
3267
|
+
"message_unpinned"
|
|
3266
3268
|
]
|
|
3267
3269
|
},
|
|
3268
3270
|
"SystemEvent": {
|
|
3269
3271
|
"type": "object",
|
|
3270
|
-
"description": "What a `system` message records; set on system messages only, whose `content` is then `null`. The names\nare the display names at the time of the event. `target` fields are set for `member_added` and\n`member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the\ninitiator
|
|
3272
|
+
"description": "What a `system` message records; set on system messages only, whose `content` is then `null`. The names\nare the display names at the time of the event. `target` fields are set for `member_added` and\n`member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the\ninitiator. `message_id` and `snippet` are set for `message_pinned` and `message_unpinned`.\n",
|
|
3271
3273
|
"required": [
|
|
3272
3274
|
"kind",
|
|
3273
3275
|
"actor_id",
|
|
@@ -3298,6 +3300,22 @@
|
|
|
3298
3300
|
},
|
|
3299
3301
|
"call": {
|
|
3300
3302
|
"$ref": "#/$defs/CallSummary"
|
|
3303
|
+
},
|
|
3304
|
+
"message_id": {
|
|
3305
|
+
"description": "The pinned or unpinned message.",
|
|
3306
|
+
"allOf": [
|
|
3307
|
+
{
|
|
3308
|
+
"$ref": "#/$defs/Id"
|
|
3309
|
+
}
|
|
3310
|
+
]
|
|
3311
|
+
},
|
|
3312
|
+
"snippet": {
|
|
3313
|
+
"type": "string",
|
|
3314
|
+
"maxLength": 64,
|
|
3315
|
+
"description": "Start of the pinned message's text at the time of the event (at most 60 characters plus `…`); empty for a\nmessage without text, which clients name by its `message_type`.\n"
|
|
3316
|
+
},
|
|
3317
|
+
"message_type": {
|
|
3318
|
+
"$ref": "#/$defs/MessageType"
|
|
3301
3319
|
}
|
|
3302
3320
|
}
|
|
3303
3321
|
},
|
|
@@ -3792,6 +3810,7 @@
|
|
|
3792
3810
|
"first_unread_message_id",
|
|
3793
3811
|
"last_read_message_id",
|
|
3794
3812
|
"last_message",
|
|
3813
|
+
"pinned_message_count",
|
|
3795
3814
|
"created_at"
|
|
3796
3815
|
],
|
|
3797
3816
|
"properties": {
|
|
@@ -3892,6 +3911,11 @@
|
|
|
3892
3911
|
}
|
|
3893
3912
|
]
|
|
3894
3913
|
},
|
|
3914
|
+
"pinned_message_count": {
|
|
3915
|
+
"type": "integer",
|
|
3916
|
+
"minimum": 0,
|
|
3917
|
+
"description": "Pinned messages the caller sees (`GET /chats/{chat_id}/pins`); clients show the pinned bar above 0."
|
|
3918
|
+
},
|
|
3895
3919
|
"created_at": {
|
|
3896
3920
|
"$ref": "#/$defs/Timestamp"
|
|
3897
3921
|
}
|
|
@@ -3958,6 +3982,77 @@
|
|
|
3958
3982
|
}
|
|
3959
3983
|
}
|
|
3960
3984
|
},
|
|
3985
|
+
"PinScope": {
|
|
3986
|
+
"type": "string",
|
|
3987
|
+
"description": "`me`: only for the caller. `everyone`: for every member of the chat.",
|
|
3988
|
+
"enum": [
|
|
3989
|
+
"me",
|
|
3990
|
+
"everyone"
|
|
3991
|
+
]
|
|
3992
|
+
},
|
|
3993
|
+
"PinMessageRequest": {
|
|
3994
|
+
"type": "object",
|
|
3995
|
+
"required": [
|
|
3996
|
+
"scope"
|
|
3997
|
+
],
|
|
3998
|
+
"properties": {
|
|
3999
|
+
"scope": {
|
|
4000
|
+
"$ref": "#/$defs/PinScope"
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
},
|
|
4004
|
+
"PinnedMessage": {
|
|
4005
|
+
"type": "object",
|
|
4006
|
+
"required": [
|
|
4007
|
+
"message",
|
|
4008
|
+
"scope",
|
|
4009
|
+
"pinned_by",
|
|
4010
|
+
"pinned_at",
|
|
4011
|
+
"can_unpin_for_everyone"
|
|
4012
|
+
],
|
|
4013
|
+
"properties": {
|
|
4014
|
+
"message": {
|
|
4015
|
+
"$ref": "#/$defs/Message"
|
|
4016
|
+
},
|
|
4017
|
+
"scope": {
|
|
4018
|
+
"$ref": "#/$defs/PinScope"
|
|
4019
|
+
},
|
|
4020
|
+
"pinned_by": {
|
|
4021
|
+
"description": "Who pinned it; the caller for `me`.",
|
|
4022
|
+
"allOf": [
|
|
4023
|
+
{
|
|
4024
|
+
"$ref": "#/$defs/Id"
|
|
4025
|
+
}
|
|
4026
|
+
]
|
|
4027
|
+
},
|
|
4028
|
+
"pinned_at": {
|
|
4029
|
+
"$ref": "#/$defs/Timestamp"
|
|
4030
|
+
},
|
|
4031
|
+
"can_unpin_for_everyone": {
|
|
4032
|
+
"type": "boolean",
|
|
4033
|
+
"description": "Whether `DELETE …/pin?scope=everyone` is allowed for the caller; always `false` for `me`."
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
},
|
|
4037
|
+
"PinnedMessagePage": {
|
|
4038
|
+
"type": "object",
|
|
4039
|
+
"required": [
|
|
4040
|
+
"items",
|
|
4041
|
+
"next_cursor"
|
|
4042
|
+
],
|
|
4043
|
+
"properties": {
|
|
4044
|
+
"items": {
|
|
4045
|
+
"type": "array",
|
|
4046
|
+
"description": "Newest pin first",
|
|
4047
|
+
"items": {
|
|
4048
|
+
"$ref": "#/$defs/PinnedMessage"
|
|
4049
|
+
}
|
|
4050
|
+
},
|
|
4051
|
+
"next_cursor": {
|
|
4052
|
+
"$ref": "#/$defs/Cursor"
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
},
|
|
3961
4056
|
"CreateChatRequest": {
|
|
3962
4057
|
"type": "object",
|
|
3963
4058
|
"required": [
|
|
@@ -6706,6 +6801,64 @@
|
|
|
6706
6801
|
"data"
|
|
6707
6802
|
]
|
|
6708
6803
|
},
|
|
6804
|
+
"ServerPinUpdateEvent": {
|
|
6805
|
+
"title": "ServerPinUpdateEvent",
|
|
6806
|
+
"description": "A message was pinned or unpinned. Scope everyone goes to every member; scope me (an own pin, or a pin for everyone hidden or shown again for you) only to your own sessions. Load GET /chats/{chat_id}/pins again, or apply the change: pinned adds the message to your pins, unpinned removes it. For scope everyone, unpinned may leave your own pin of the message, so reload in that case.",
|
|
6807
|
+
"type": "object",
|
|
6808
|
+
"properties": {
|
|
6809
|
+
"type": {
|
|
6810
|
+
"const": "pin_update"
|
|
6811
|
+
},
|
|
6812
|
+
"event_id": {
|
|
6813
|
+
"$ref": "#/$defs/Id"
|
|
6814
|
+
},
|
|
6815
|
+
"chat_id": {
|
|
6816
|
+
"$ref": "#/$defs/Id"
|
|
6817
|
+
},
|
|
6818
|
+
"data": {
|
|
6819
|
+
"type": "object",
|
|
6820
|
+
"properties": {
|
|
6821
|
+
"message_id": {
|
|
6822
|
+
"$ref": "#/$defs/Id"
|
|
6823
|
+
},
|
|
6824
|
+
"action": {
|
|
6825
|
+
"type": "string",
|
|
6826
|
+
"enum": [
|
|
6827
|
+
"pinned",
|
|
6828
|
+
"unpinned"
|
|
6829
|
+
]
|
|
6830
|
+
},
|
|
6831
|
+
"scope": {
|
|
6832
|
+
"$ref": "#/$defs/PinScope"
|
|
6833
|
+
},
|
|
6834
|
+
"actor_id": {
|
|
6835
|
+
"$ref": "#/$defs/Id"
|
|
6836
|
+
},
|
|
6837
|
+
"at": {
|
|
6838
|
+
"$ref": "#/$defs/Timestamp"
|
|
6839
|
+
},
|
|
6840
|
+
"pinned_message_count": {
|
|
6841
|
+
"type": "integer",
|
|
6842
|
+
"minimum": 0,
|
|
6843
|
+
"description": "Chat.pinned_message_count for the recipient after the change."
|
|
6844
|
+
}
|
|
6845
|
+
},
|
|
6846
|
+
"required": [
|
|
6847
|
+
"message_id",
|
|
6848
|
+
"action",
|
|
6849
|
+
"scope",
|
|
6850
|
+
"actor_id",
|
|
6851
|
+
"at"
|
|
6852
|
+
]
|
|
6853
|
+
}
|
|
6854
|
+
},
|
|
6855
|
+
"required": [
|
|
6856
|
+
"type",
|
|
6857
|
+
"event_id",
|
|
6858
|
+
"chat_id",
|
|
6859
|
+
"data"
|
|
6860
|
+
]
|
|
6861
|
+
},
|
|
6709
6862
|
"ServerPresenceEvent": {
|
|
6710
6863
|
"title": "ServerPresenceEvent",
|
|
6711
6864
|
"description": "A user came online or went offline, as far as their privacy settings allow.",
|
|
@@ -7229,6 +7382,9 @@
|
|
|
7229
7382
|
{
|
|
7230
7383
|
"$ref": "#/$defs/ServerMessageEvent"
|
|
7231
7384
|
},
|
|
7385
|
+
{
|
|
7386
|
+
"$ref": "#/$defs/ServerPinUpdateEvent"
|
|
7387
|
+
},
|
|
7232
7388
|
{
|
|
7233
7389
|
"$ref": "#/$defs/ServerPresenceEvent"
|
|
7234
7390
|
},
|
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.42",
|
|
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": {
|