@hadoku/rooms-server 0.45.100 → 0.45.102
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/dist/chat/history.d.ts +8 -0
- package/dist/chat/history.d.ts.map +1 -1
- package/dist/chat/history.js +52 -8
- package/dist/chat/room-chat.d.ts +83 -3
- package/dist/chat/room-chat.d.ts.map +1 -1
- package/dist/chat/room-chat.js +137 -1
- package/dist/room/serve-room.d.ts +5 -3
- package/dist/room/serve-room.d.ts.map +1 -1
- package/dist/room/serve-room.js +50 -1
- package/package.json +3 -3
package/dist/chat/history.d.ts
CHANGED
|
@@ -29,6 +29,14 @@ export interface ChatHistoryConfig<M extends ChatHistoryRecord> {
|
|
|
29
29
|
}
|
|
30
30
|
export interface ChatHistoryStore<M extends ChatHistoryRecord> {
|
|
31
31
|
appendMessage(roomId: string, msg: M): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Replace one stored message with `mutate(message)` (a reaction added or
|
|
34
|
+
* removed). Returns the new message, or null when the room holds no message
|
|
35
|
+
* `id` or `mutate` returns null (nothing changed). The file is rewritten
|
|
36
|
+
* whole: a room keeps at most `maxMessages` lines, and an in-place edit of
|
|
37
|
+
* an append-only log is a second format nobody else reads.
|
|
38
|
+
*/
|
|
39
|
+
updateMessage(roomId: string, id: string, mutate: (msg: M) => M | null): Promise<M | null>;
|
|
32
40
|
recentMessages(roomId: string, limit?: number): Promise<M[]>;
|
|
33
41
|
pagedMessages(roomId: string, opts?: {
|
|
34
42
|
beforeTs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/chat/history.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,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,CAAC,IAAI,CAAC,CAAC;IACrD;;;;;;OAMG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3F,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACzG;0BACsB;IACtB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvF;6CACyC;IACzC,aAAa,IAAI,IAAI,CAAC;CACvB;AAID,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,iBAAiB,EAChE,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC3B,gBAAgB,CAAC,CAAC,CAAC,CA4MrB"}
|
package/dist/chat/history.js
CHANGED
|
@@ -33,6 +33,10 @@ export function createChatHistoryStore(config) {
|
|
|
33
33
|
const memory = new Map();
|
|
34
34
|
const fileLineCount = new Map();
|
|
35
35
|
const pendingClears = new Map();
|
|
36
|
+
/** Each room's file writes, in order. An append landing while a rewrite's
|
|
37
|
+
* temp file is in flight would be renamed away; one queue per room keeps
|
|
38
|
+
* every write after the one before it. */
|
|
39
|
+
const writeQueues = new Map();
|
|
36
40
|
const safeRoomId = config.safeRoomId ?? DEFAULT_SAFE_ROOMID_RE;
|
|
37
41
|
function emit(level, event, roomId, fields) {
|
|
38
42
|
config.onEvent?.(level, event, roomId, fields);
|
|
@@ -64,19 +68,34 @@ export function createChatHistoryStore(config) {
|
|
|
64
68
|
emit('warn', 'chat.persist_unlink_failed', roomId, { err_message: String(err) });
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
|
-
|
|
71
|
+
function queued(roomId, write) {
|
|
72
|
+
const next = (writeQueues.get(roomId) ?? Promise.resolve()).then(write);
|
|
73
|
+
writeQueues.set(roomId, next);
|
|
74
|
+
void next.finally(() => { if (writeQueues.get(roomId) === next)
|
|
75
|
+
writeQueues.delete(roomId); });
|
|
76
|
+
return next;
|
|
77
|
+
}
|
|
78
|
+
async function rewrite(roomId, fp, list) {
|
|
79
|
+
const tmp = `${fp}.tmp`;
|
|
80
|
+
await writeFile(tmp, `${list.map((m) => JSON.stringify(m)).join('\n')}${list.length ? '\n' : ''}`);
|
|
81
|
+
await rename(tmp, fp);
|
|
82
|
+
fileLineCount.set(roomId, list.length);
|
|
83
|
+
}
|
|
84
|
+
function persistAppend(roomId, msg, list) {
|
|
68
85
|
const fp = filePath(roomId);
|
|
69
86
|
if (!fp)
|
|
70
|
-
return;
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
// A snapshot: a compaction rewrite written later from the live list would
|
|
89
|
+
// already hold messages whose own queued appends follow it.
|
|
90
|
+
const snapshot = list.slice();
|
|
91
|
+
return queued(roomId, () => writeAppend(roomId, fp, msg, snapshot));
|
|
92
|
+
}
|
|
93
|
+
async function writeAppend(roomId, fp, msg, list) {
|
|
71
94
|
try {
|
|
72
95
|
await mkdir(dirname(fp), { recursive: true });
|
|
73
96
|
const lineCount = fileLineCount.get(roomId) ?? 0;
|
|
74
97
|
if (lineCount >= config.maxMessages * 2) {
|
|
75
|
-
|
|
76
|
-
const body = `${list.map((m) => JSON.stringify(m)).join('\n')}\n`;
|
|
77
|
-
await writeFile(tmp, body);
|
|
78
|
-
await rename(tmp, fp);
|
|
79
|
-
fileLineCount.set(roomId, list.length);
|
|
98
|
+
await rewrite(roomId, fp, list);
|
|
80
99
|
}
|
|
81
100
|
else {
|
|
82
101
|
await appendFile(fp, `${JSON.stringify(msg)}\n`);
|
|
@@ -102,6 +121,31 @@ export function createChatHistoryStore(config) {
|
|
|
102
121
|
list.splice(0, list.length - config.maxMessages);
|
|
103
122
|
await persistAppend(roomId, msg, list);
|
|
104
123
|
}
|
|
124
|
+
async function updateMessage(roomId, id, mutate) {
|
|
125
|
+
const list = memory.get(roomId);
|
|
126
|
+
const at = list ? list.findIndex((m) => m.id === id) : -1;
|
|
127
|
+
if (!list || at < 0)
|
|
128
|
+
return null;
|
|
129
|
+
const next = mutate(list[at]);
|
|
130
|
+
if (!next)
|
|
131
|
+
return null;
|
|
132
|
+
list[at] = next;
|
|
133
|
+
const fp = filePath(roomId);
|
|
134
|
+
if (fp) {
|
|
135
|
+
// A snapshot of the list as of this change, written in queue order.
|
|
136
|
+
const snapshot = list.slice();
|
|
137
|
+
await queued(roomId, async () => {
|
|
138
|
+
try {
|
|
139
|
+
await mkdir(dirname(fp), { recursive: true });
|
|
140
|
+
await rewrite(roomId, fp, snapshot);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
emit('warn', 'chat.persist_failed', roomId, { err_message: String(err) });
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return next;
|
|
148
|
+
}
|
|
105
149
|
async function recentMessages(roomId, limit = config.maxMessages) {
|
|
106
150
|
const list = memory.get(roomId) || [];
|
|
107
151
|
return list.slice(-limit);
|
|
@@ -192,5 +236,5 @@ export function createChatHistoryStore(config) {
|
|
|
192
236
|
memory.clear();
|
|
193
237
|
fileLineCount.clear();
|
|
194
238
|
}
|
|
195
|
-
return { appendMessage, recentMessages, pagedMessages, clearRoomChat, loadFromDisk, resetForTests };
|
|
239
|
+
return { appendMessage, updateMessage, recentMessages, pagedMessages, clearRoomChat, loadFromDisk, resetForTests };
|
|
196
240
|
}
|
package/dist/chat/room-chat.d.ts
CHANGED
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
* the app's own events.
|
|
17
17
|
*
|
|
18
18
|
* THE WIRE IS WATCHPARTY'S, UNCHANGED: the client emits `join` (watchparty's
|
|
19
|
-
* join payload; only `room_key` is read here)
|
|
20
|
-
*
|
|
21
|
-
* `
|
|
19
|
+
* join payload; only `room_key` is read here), `chat_send` (`{ text, style?,
|
|
20
|
+
* images?, reply_to? }`), `chat_react` (`{ id, emoji, on }`) and
|
|
21
|
+
* `chat_typing` (`{ typing }`), and receives `chat_history` (`{ messages }`),
|
|
22
|
+
* `chat_broadcast`, `chat_reaction` (`{ id, reactions }`), `chat_typing`
|
|
23
|
+
* (`{ client_id, author?, typing }`) and `error` (`{ code, message }`). Same event names and
|
|
22
24
|
* payloads as watchparty's room socket, so the chat client is one piece of
|
|
23
25
|
* code whichever server it talks to.
|
|
24
26
|
*
|
|
@@ -40,6 +42,31 @@ export declare const CHAT_MAX_STYLE_LENGTH = 64;
|
|
|
40
42
|
export declare const CHAT_MAX_IMAGE_DIMENSION = 20000;
|
|
41
43
|
export declare const CHAT_MAX_IMAGE_TITLE_LENGTH = 300;
|
|
42
44
|
export declare const CHAT_HISTORY_JOIN_LIMIT = 100;
|
|
45
|
+
/** Distinct emoji one message may carry (Discord's own cap is 20). */
|
|
46
|
+
export declare const CHAT_MAX_REACTIONS = 20;
|
|
47
|
+
/** A reaction is one emoji: a ZWJ family sequence with skin tones runs to ~35
|
|
48
|
+
* UTF-16 units, nothing legitimate past this. */
|
|
49
|
+
export declare const CHAT_MAX_EMOJI_LENGTH = 48;
|
|
50
|
+
/** The message ids a `reply_to` may name: the store's own ids (UUIDs), with
|
|
51
|
+
* room for a host's newId. Anything else is refused rather than stored. */
|
|
52
|
+
export declare const CHAT_MESSAGE_ID_RE: RegExp;
|
|
53
|
+
/**
|
|
54
|
+
* True when `s` is one emoji and nothing else. Every code point must be part
|
|
55
|
+
* of an emoji sequence (a pictograph, a regional indicator, a skin-tone
|
|
56
|
+
* modifier, ZWJ, a variation selector, a keycap, a tag), and at least one must
|
|
57
|
+
* be a pictograph, a flag letter or a keycap, so a bare `1` or `#` (which
|
|
58
|
+
* Unicode also counts as `\p{Emoji}`) is refused. A reaction is rendered as
|
|
59
|
+
* text; this is about keeping a sentence out of a reaction pill, not about
|
|
60
|
+
* markup.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isReactionEmoji(s: unknown): s is string;
|
|
63
|
+
/** Who reacted with one emoji, in the order they did. `by` holds reactor
|
|
64
|
+
* handles (a participant handle, or the connection id for a sender with
|
|
65
|
+
* none) — the same ids `author` already puts on the wire, never a name. */
|
|
66
|
+
export interface ChatReaction {
|
|
67
|
+
emoji: string;
|
|
68
|
+
by: string[];
|
|
69
|
+
}
|
|
43
70
|
export interface ChatImageInput {
|
|
44
71
|
key: string;
|
|
45
72
|
w: number;
|
|
@@ -51,6 +78,17 @@ export interface ChatSendInput {
|
|
|
51
78
|
text: string;
|
|
52
79
|
style?: string;
|
|
53
80
|
images?: ChatImageInput[];
|
|
81
|
+
/** The id of the message this one answers. Not checked against the
|
|
82
|
+
* history: the original may have rolled out of it, and the client says
|
|
83
|
+
* so rather than the send failing. */
|
|
84
|
+
replyTo?: string;
|
|
85
|
+
}
|
|
86
|
+
/** What a `chat_react` carries once validated. */
|
|
87
|
+
export interface ChatReactInput {
|
|
88
|
+
id: string;
|
|
89
|
+
emoji: string;
|
|
90
|
+
/** true adds the caller's reaction, false takes it back. */
|
|
91
|
+
on: boolean;
|
|
54
92
|
}
|
|
55
93
|
/** The stored message. Hosts may extend it (the history store is generic). */
|
|
56
94
|
export interface RoomChatMessage extends ChatHistoryRecord {
|
|
@@ -60,6 +98,9 @@ export interface RoomChatMessage extends ChatHistoryRecord {
|
|
|
60
98
|
text: string;
|
|
61
99
|
style?: string;
|
|
62
100
|
images?: ChatImageInput[];
|
|
101
|
+
replyTo?: string;
|
|
102
|
+
/** In first-reacted order, each with its reactors. Absent when none. */
|
|
103
|
+
reactions?: ChatReaction[];
|
|
63
104
|
isSystem?: boolean;
|
|
64
105
|
systemType?: string;
|
|
65
106
|
}
|
|
@@ -85,10 +126,23 @@ export interface ChatBroadcastPayload {
|
|
|
85
126
|
ts: number;
|
|
86
127
|
style?: string;
|
|
87
128
|
images?: ChatImageInput[];
|
|
129
|
+
reply_to?: string;
|
|
130
|
+
reactions?: ChatReaction[];
|
|
88
131
|
isSystem: boolean;
|
|
89
132
|
systemType?: string;
|
|
90
133
|
template?: string;
|
|
91
134
|
}
|
|
135
|
+
/** `chat_reaction`: a message's whole reaction list after a change. */
|
|
136
|
+
export interface ChatReactionPayload {
|
|
137
|
+
id: string;
|
|
138
|
+
reactions: ChatReaction[];
|
|
139
|
+
}
|
|
140
|
+
/** `chat_typing`, as relayed to the rest of the room. */
|
|
141
|
+
export interface ChatTypingPayload {
|
|
142
|
+
client_id: string;
|
|
143
|
+
author?: string;
|
|
144
|
+
typing: boolean;
|
|
145
|
+
}
|
|
92
146
|
/**
|
|
93
147
|
* Validate a `chat_send` payload, or null. Kept identical to watchparty's Zod
|
|
94
148
|
* `ChatSend` (`@watchparty/shared` protocol.ts), which this package cannot
|
|
@@ -97,6 +151,18 @@ export interface ChatBroadcastPayload {
|
|
|
97
151
|
* Unknown fields are dropped, as Zod's object parse drops them.
|
|
98
152
|
*/
|
|
99
153
|
export declare function parseChatSend(payload: unknown): ChatSendInput | null;
|
|
154
|
+
/** Validate a `chat_react` payload, or null. */
|
|
155
|
+
export declare function parseChatReact(payload: unknown): ChatReactInput | null;
|
|
156
|
+
/** Validate a `chat_typing` payload: the boolean, or null. */
|
|
157
|
+
export declare function parseChatTyping(payload: unknown): boolean | null;
|
|
158
|
+
/** The handle a reaction is recorded under: who, not which connection. */
|
|
159
|
+
export declare function reactorHandle(sender: Pick<ChatSender, 'clientId' | 'author'>): string;
|
|
160
|
+
/**
|
|
161
|
+
* `reactions` with `handle`'s `emoji` added (`on`) or removed, or null when
|
|
162
|
+
* nothing changes (already there, not there, or a new emoji past the cap).
|
|
163
|
+
* Pure; the order is first-reacted, as Discord shows it.
|
|
164
|
+
*/
|
|
165
|
+
export declare function applyReaction(reactions: ChatReaction[] | undefined, emoji: string, handle: string, on: boolean): ChatReaction[] | null;
|
|
100
166
|
/** Fill the `{name}` token of a stored system line. */
|
|
101
167
|
export declare function fillChatName(text: string, name: string | null | undefined): string;
|
|
102
168
|
/** The wire shape of a stored message, named by `who` (live or as presented). */
|
|
@@ -112,12 +178,23 @@ export type ChatSendOutcome<M> = {
|
|
|
112
178
|
ok: false;
|
|
113
179
|
reason: 'rate_limited' | 'invalid' | 'append_failed';
|
|
114
180
|
};
|
|
181
|
+
export type ChatReactOutcome = {
|
|
182
|
+
ok: true;
|
|
183
|
+
payload: ChatReactionPayload;
|
|
184
|
+
} | {
|
|
185
|
+
ok: false;
|
|
186
|
+
reason: 'rate_limited' | 'invalid' | 'not_found' | 'unchanged';
|
|
187
|
+
};
|
|
115
188
|
export interface RoomChatOptions<M extends RoomChatMessage> {
|
|
116
189
|
store: ChatHistoryStore<M>;
|
|
117
190
|
/** Validate a send. Default `parseChatSend`. */
|
|
118
191
|
parse?: (payload: unknown) => ChatSendInput | null;
|
|
119
192
|
/** Per-connection rate limit; false refuses the send. Default: no limit. */
|
|
120
193
|
allow?: (clientId: string) => boolean;
|
|
194
|
+
/** Per-connection rate limit for reactions; false refuses one. Separate
|
|
195
|
+
* from `allow` so reacting never spends the budget for talking. Default:
|
|
196
|
+
* no limit. */
|
|
197
|
+
allowReact?: (clientId: string) => boolean;
|
|
121
198
|
newId?: () => string;
|
|
122
199
|
now?: () => number;
|
|
123
200
|
}
|
|
@@ -125,6 +202,9 @@ export interface RoomChat<M extends RoomChatMessage> {
|
|
|
125
202
|
/** Parse, rate-limit and store one `chat_send`; returns the payload to
|
|
126
203
|
* broadcast. Never throws. The caller broadcasts (it owns the transport). */
|
|
127
204
|
send(roomId: string, sender: ChatSender, payload: unknown): Promise<ChatSendOutcome<M>>;
|
|
205
|
+
/** Parse, rate-limit and apply one `chat_react`; returns the `chat_reaction`
|
|
206
|
+
* payload to broadcast. Never throws. A system line takes no reactions. */
|
|
207
|
+
react(roomId: string, sender: Pick<ChatSender, 'clientId' | 'author'>, payload: unknown): Promise<ChatReactOutcome>;
|
|
128
208
|
store: ChatHistoryStore<M>;
|
|
129
209
|
}
|
|
130
210
|
export declare function createRoomChat<M extends RoomChatMessage>(opts: RoomChatOptions<M>): RoomChat<M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-chat.d.ts","sourceRoot":"","sources":["../../src/chat/room-chat.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"room-chat.d.ts","sourceRoot":"","sources":["../../src/chat/room-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAExE;4EAC4E;AAC5E,eAAO,MAAM,iBAAiB,QAAgD,CAAC;AAC/E,gEAAgE;AAChE,eAAO,MAAM,eAAe,WAAW,CAAC;AAExC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC;kDACkD;AAClD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC;4EAC4E;AAC5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,30 @@ export const CHAT_MAX_STYLE_LENGTH = 64;
|
|
|
9
9
|
export const CHAT_MAX_IMAGE_DIMENSION = 20_000;
|
|
10
10
|
export const CHAT_MAX_IMAGE_TITLE_LENGTH = 300;
|
|
11
11
|
export const CHAT_HISTORY_JOIN_LIMIT = 100;
|
|
12
|
+
/** Distinct emoji one message may carry (Discord's own cap is 20). */
|
|
13
|
+
export const CHAT_MAX_REACTIONS = 20;
|
|
14
|
+
/** A reaction is one emoji: a ZWJ family sequence with skin tones runs to ~35
|
|
15
|
+
* UTF-16 units, nothing legitimate past this. */
|
|
16
|
+
export const CHAT_MAX_EMOJI_LENGTH = 48;
|
|
17
|
+
/** The message ids a `reply_to` may name: the store's own ids (UUIDs), with
|
|
18
|
+
* room for a host's newId. Anything else is refused rather than stored. */
|
|
19
|
+
export const CHAT_MESSAGE_ID_RE = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
20
|
+
/**
|
|
21
|
+
* True when `s` is one emoji and nothing else. Every code point must be part
|
|
22
|
+
* of an emoji sequence (a pictograph, a regional indicator, a skin-tone
|
|
23
|
+
* modifier, ZWJ, a variation selector, a keycap, a tag), and at least one must
|
|
24
|
+
* be a pictograph, a flag letter or a keycap, so a bare `1` or `#` (which
|
|
25
|
+
* Unicode also counts as `\p{Emoji}`) is refused. A reaction is rendered as
|
|
26
|
+
* text; this is about keeping a sentence out of a reaction pill, not about
|
|
27
|
+
* markup.
|
|
28
|
+
*/
|
|
29
|
+
export function isReactionEmoji(s) {
|
|
30
|
+
if (typeof s !== 'string' || s.length === 0 || s.length > CHAT_MAX_EMOJI_LENGTH)
|
|
31
|
+
return false;
|
|
32
|
+
if (!/^(?:\p{Emoji}|\p{Emoji_Modifier}|\u200d|\ufe0f|\u20e3|[\u{e0020}-\u{e007f}])+$/u.test(s))
|
|
33
|
+
return false;
|
|
34
|
+
return /\p{Extended_Pictographic}|\p{Regional_Indicator}|\u20e3/u.test(s);
|
|
35
|
+
}
|
|
12
36
|
function isInt(n, max) {
|
|
13
37
|
return typeof n === 'number' && Number.isInteger(n) && n >= 0 && n <= max;
|
|
14
38
|
}
|
|
@@ -53,10 +77,62 @@ export function parseChatSend(payload) {
|
|
|
53
77
|
}
|
|
54
78
|
out.images = images;
|
|
55
79
|
}
|
|
80
|
+
if (p.reply_to !== undefined) {
|
|
81
|
+
if (typeof p.reply_to !== 'string' || !CHAT_MESSAGE_ID_RE.test(p.reply_to))
|
|
82
|
+
return null;
|
|
83
|
+
out.replyTo = p.reply_to;
|
|
84
|
+
}
|
|
56
85
|
if (out.text.length === 0 && (out.images?.length ?? 0) === 0)
|
|
57
86
|
return null;
|
|
58
87
|
return out;
|
|
59
88
|
}
|
|
89
|
+
/** Validate a `chat_react` payload, or null. */
|
|
90
|
+
export function parseChatReact(payload) {
|
|
91
|
+
if (!payload || typeof payload !== 'object')
|
|
92
|
+
return null;
|
|
93
|
+
const p = payload;
|
|
94
|
+
if (typeof p.id !== 'string' || !CHAT_MESSAGE_ID_RE.test(p.id))
|
|
95
|
+
return null;
|
|
96
|
+
if (!isReactionEmoji(p.emoji))
|
|
97
|
+
return null;
|
|
98
|
+
if (typeof p.on !== 'boolean')
|
|
99
|
+
return null;
|
|
100
|
+
return { id: p.id, emoji: p.emoji, on: p.on };
|
|
101
|
+
}
|
|
102
|
+
/** Validate a `chat_typing` payload: the boolean, or null. */
|
|
103
|
+
export function parseChatTyping(payload) {
|
|
104
|
+
if (!payload || typeof payload !== 'object')
|
|
105
|
+
return null;
|
|
106
|
+
const t = payload.typing;
|
|
107
|
+
return typeof t === 'boolean' ? t : null;
|
|
108
|
+
}
|
|
109
|
+
/** The handle a reaction is recorded under: who, not which connection. */
|
|
110
|
+
export function reactorHandle(sender) {
|
|
111
|
+
return sender.author ?? sender.clientId;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* `reactions` with `handle`'s `emoji` added (`on`) or removed, or null when
|
|
115
|
+
* nothing changes (already there, not there, or a new emoji past the cap).
|
|
116
|
+
* Pure; the order is first-reacted, as Discord shows it.
|
|
117
|
+
*/
|
|
118
|
+
export function applyReaction(reactions, emoji, handle, on) {
|
|
119
|
+
const list = reactions ?? [];
|
|
120
|
+
const at = list.findIndex((r) => r.emoji === emoji);
|
|
121
|
+
if (on) {
|
|
122
|
+
if (at >= 0) {
|
|
123
|
+
if (list[at].by.includes(handle))
|
|
124
|
+
return null;
|
|
125
|
+
return list.map((r, i) => (i === at ? { emoji, by: [...r.by, handle] } : r));
|
|
126
|
+
}
|
|
127
|
+
if (list.length >= CHAT_MAX_REACTIONS)
|
|
128
|
+
return null;
|
|
129
|
+
return [...list, { emoji, by: [handle] }];
|
|
130
|
+
}
|
|
131
|
+
if (at < 0 || !list[at].by.includes(handle))
|
|
132
|
+
return null;
|
|
133
|
+
const by = list[at].by.filter((h) => h !== handle);
|
|
134
|
+
return by.length ? list.map((r, i) => (i === at ? { emoji, by } : r)) : list.filter((_, i) => i !== at);
|
|
135
|
+
}
|
|
60
136
|
/** Fill the `{name}` token of a stored system line. */
|
|
61
137
|
export function fillChatName(text, name) {
|
|
62
138
|
return text.split(CHAT_NAME_TOKEN).join(name || 'Someone');
|
|
@@ -74,6 +150,8 @@ export function toChatBroadcast(msg, who) {
|
|
|
74
150
|
ts: msg.ts,
|
|
75
151
|
style: msg.style,
|
|
76
152
|
images: msg.images,
|
|
153
|
+
...(msg.replyTo ? { reply_to: msg.replyTo } : {}),
|
|
154
|
+
...(msg.reactions?.length ? { reactions: msg.reactions } : {}),
|
|
77
155
|
isSystem: !!msg.isSystem,
|
|
78
156
|
systemType: msg.systemType,
|
|
79
157
|
...(templated ? { template: msg.text } : {}),
|
|
@@ -100,6 +178,7 @@ export function createRoomChat(opts) {
|
|
|
100
178
|
// Undefined rather than [] when there are none, so an image-less message
|
|
101
179
|
// is byte-identical to one sent before attachments existed.
|
|
102
180
|
images: data.images?.length ? data.images : undefined,
|
|
181
|
+
...(data.replyTo ? { replyTo: data.replyTo } : {}),
|
|
103
182
|
isSystem: false,
|
|
104
183
|
};
|
|
105
184
|
try {
|
|
@@ -110,7 +189,38 @@ export function createRoomChat(opts) {
|
|
|
110
189
|
}
|
|
111
190
|
return { ok: true, message, broadcast: toChatBroadcast(message, sender) };
|
|
112
191
|
}
|
|
113
|
-
|
|
192
|
+
async function react(roomId, sender, payload) {
|
|
193
|
+
if (opts.allowReact && !opts.allowReact(sender.clientId))
|
|
194
|
+
return { ok: false, reason: 'rate_limited' };
|
|
195
|
+
const data = parseChatReact(payload);
|
|
196
|
+
if (!data)
|
|
197
|
+
return { ok: false, reason: 'invalid' };
|
|
198
|
+
let found = false;
|
|
199
|
+
let updated;
|
|
200
|
+
try {
|
|
201
|
+
updated = await opts.store.updateMessage(roomId, data.id, (msg) => {
|
|
202
|
+
found = true;
|
|
203
|
+
if (msg.isSystem)
|
|
204
|
+
return null;
|
|
205
|
+
const reactions = applyReaction(msg.reactions, data.emoji, reactorHandle(sender), data.on);
|
|
206
|
+
if (!reactions)
|
|
207
|
+
return null;
|
|
208
|
+
const next = { ...msg };
|
|
209
|
+
if (reactions.length)
|
|
210
|
+
next.reactions = reactions;
|
|
211
|
+
else
|
|
212
|
+
delete next.reactions;
|
|
213
|
+
return next;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return { ok: false, reason: 'invalid' };
|
|
218
|
+
}
|
|
219
|
+
if (!updated)
|
|
220
|
+
return { ok: false, reason: found ? 'unchanged' : 'not_found' };
|
|
221
|
+
return { ok: true, payload: { id: updated.id, reactions: updated.reactions ?? [] } };
|
|
222
|
+
}
|
|
223
|
+
return { send, react, store: opts.store };
|
|
114
224
|
}
|
|
115
225
|
/**
|
|
116
226
|
* The body of `GET <prefix>/api/rooms/:id/chat?key=&limit=&before=`, with no
|
|
@@ -236,8 +346,34 @@ export function serveRoomChat(io, opts) {
|
|
|
236
346
|
}
|
|
237
347
|
broadcast(admission.roomId, outcome.broadcast);
|
|
238
348
|
});
|
|
349
|
+
socket.on('chat_react', async (payload) => {
|
|
350
|
+
const admission = admitted.get(socket.id);
|
|
351
|
+
if (!admission)
|
|
352
|
+
return refuse('auth/forbidden', 'join the room before reacting');
|
|
353
|
+
const outcome = await chat.react(admission.roomId, admission.sender(), payload);
|
|
354
|
+
if (!outcome.ok) {
|
|
355
|
+
if (outcome.reason === 'unchanged')
|
|
356
|
+
return;
|
|
357
|
+
emit('warn', 'chat.react_refused', { sid: socket.id, room_id: admission.roomId, reason: outcome.reason });
|
|
358
|
+
if (outcome.reason === 'rate_limited')
|
|
359
|
+
refuse('rate/limited', 'reaction rate limit');
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
nsp.to(chatChannel(admission.roomId)).emit('chat_reaction', outcome.payload);
|
|
363
|
+
});
|
|
364
|
+
socket.on('chat_typing', (payload) => {
|
|
365
|
+
const admission = admitted.get(socket.id);
|
|
366
|
+
const typing = parseChatTyping(payload);
|
|
367
|
+
if (!admission || typing === null)
|
|
368
|
+
return;
|
|
369
|
+
const s = admission.sender();
|
|
370
|
+
socket.to(chatChannel(admission.roomId)).emit('chat_typing', { client_id: s.clientId, ...(s.author ? { author: s.author } : {}), typing });
|
|
371
|
+
});
|
|
239
372
|
socket.on('disconnect', () => {
|
|
373
|
+
const admission = admitted.get(socket.id);
|
|
240
374
|
admitted.delete(socket.id);
|
|
375
|
+
if (admission)
|
|
376
|
+
socket.to(chatChannel(admission.roomId)).emit('chat_typing', { client_id: admission.sender().clientId, typing: false });
|
|
241
377
|
});
|
|
242
378
|
});
|
|
243
379
|
return { ...chat, namespace: nsp, members, present, broadcast };
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
* one piece of code whichever server it talks to:
|
|
9
9
|
*
|
|
10
10
|
* client → `join` (watchparty's join payload), `identity_update`
|
|
11
|
-
* (`{ name?, sprite?, avatar? }`), `chat_send`, `
|
|
12
|
-
* `presence_ping`; anything else is
|
|
11
|
+
* (`{ name?, sprite?, avatar? }`), `chat_send`, `chat_react`,
|
|
12
|
+
* `chat_typing`, `time_ping`, `presence_ping`; anything else is
|
|
13
|
+
* ignored (but counts as traffic)
|
|
13
14
|
* server → `snapshot` (the join ack: a room with nothing playing),
|
|
14
15
|
* `presence { users }` (`presenceUser` rows), `chat_history`,
|
|
15
|
-
* `chat_broadcast`, `
|
|
16
|
+
* `chat_broadcast`, `chat_reaction`, `chat_typing`, `time_pong`,
|
|
17
|
+
* `error { code, message }`
|
|
16
18
|
*
|
|
17
19
|
* PRESENCE IS THE APP'S TRACKER. `presence` is the app's own
|
|
18
20
|
* `PresenceTracker` — the instance its seats already listen to — never one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve-room.d.ts","sourceRoot":"","sources":["../../src/room/serve-room.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serve-room.d.ts","sourceRoot":"","sources":["../../src/room/serve-room.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAEL,KAAK,oBAAoB,EAA0B,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAC9H,MAAM,sBAAsB,CAAC;AAE9B,2DAA2D;AAC3D,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,MAAM,CAAC;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACtD,MA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U,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,CAAC,CAAC;QAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG,SAAS,CAAC;IAClG,6DAA6D;IAC7D,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,UAAU,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IAC1E,gGAAgG;IAChG,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,uDAAuD;IACvD,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IAChE,6EAA6E;IAC7E,KAAK,IAAI,IAAI,CAAC;CACf;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAMD,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAc7E;AAuBD,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,eAAe,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAsazI"}
|
package/dist/room/serve-room.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRoomPresence, presenceUser } from '../room-presence.js';
|
|
2
|
-
import { createRoomChat, defaultPresent, toChatBroadcast, CHAT_HISTORY_JOIN_LIMIT, CHAT_NAME_TOKEN, } from '../chat/room-chat.js';
|
|
2
|
+
import { createRoomChat, defaultPresent, toChatBroadcast, parseChatTyping, CHAT_HISTORY_JOIN_LIMIT, CHAT_NAME_TOKEN, } from '../chat/room-chat.js';
|
|
3
3
|
/** The socket.io room a served room's sockets are in. */
|
|
4
4
|
export function roomChannel(roomId) {
|
|
5
5
|
return `room:${roomId}`;
|
|
@@ -31,6 +31,8 @@ function isRefusal(a) {
|
|
|
31
31
|
return 'error' in a;
|
|
32
32
|
}
|
|
33
33
|
const MAX_TAB_ID_LENGTH = 64;
|
|
34
|
+
/** The fewest ms between two relayed `chat_typing { typing: true }` of one connection. */
|
|
35
|
+
const TYPING_RELAY_MIN_MS = 1000;
|
|
34
36
|
export function serveRoom(io, opts) {
|
|
35
37
|
const nsp = io.of(opts.namespace ?? '/room');
|
|
36
38
|
const chat = createRoomChat(opts);
|
|
@@ -173,9 +175,19 @@ export function serveRoom(io, opts) {
|
|
|
173
175
|
accounts.delete(accountId);
|
|
174
176
|
resolvedAt.delete(accountId);
|
|
175
177
|
}
|
|
178
|
+
// A connection that goes while typing must not leave "is typing…" up.
|
|
179
|
+
if (c.typing)
|
|
180
|
+
relayTyping(c, false);
|
|
176
181
|
void c.socket.leave(roomChannel(c.admission.roomId));
|
|
177
182
|
sendPresence(c.admission.roomId);
|
|
178
183
|
}
|
|
184
|
+
function relayTyping(c, typing) {
|
|
185
|
+
c.typing = typing;
|
|
186
|
+
const m = memberOf(c);
|
|
187
|
+
c.socket.to(roomChannel(c.admission.roomId)).emit('chat_typing', {
|
|
188
|
+
client_id: m.clientId, ...(m.author ? { author: m.author } : {}), typing,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
179
191
|
/** Same-tab takeover (see the file header). */
|
|
180
192
|
function retireSameTab(socket, admission, tabId) {
|
|
181
193
|
if (!tabId)
|
|
@@ -390,8 +402,45 @@ export function serveRoom(io, opts) {
|
|
|
390
402
|
return refuse(outcome.reason === 'rate_limited' ? 'rate/limited' : 'server/error', outcome.reason === 'rate_limited' ? 'chat rate limit' : outcome.reason === 'append_failed' ? 'chat append failed' : 'invalid chat');
|
|
391
403
|
}
|
|
392
404
|
broadcast(c.admission.roomId, outcome.broadcast);
|
|
405
|
+
// The line landed: whatever they were typing is sent. Every client
|
|
406
|
+
// clears it on the broadcast too; this is for a client that never sends
|
|
407
|
+
// its own `typing: false`.
|
|
408
|
+
c.typing = false;
|
|
393
409
|
opts.onChat?.(socket, c.admission, outcome.message);
|
|
394
410
|
});
|
|
411
|
+
socket.on('chat_react', async (payload) => {
|
|
412
|
+
const c = conns.get(socket.id);
|
|
413
|
+
if (!c)
|
|
414
|
+
return refuse('auth/forbidden', 'join the room before reacting');
|
|
415
|
+
const outcome = await chat.react(c.admission.roomId, senderOf(memberOf(c)), payload);
|
|
416
|
+
if (!outcome.ok) {
|
|
417
|
+
// Toggling to the state it is already in is a double click, not a fault.
|
|
418
|
+
if (outcome.reason === 'unchanged')
|
|
419
|
+
return;
|
|
420
|
+
log('warn', 'room.react_refused', { sid: socket.id, room_id: c.admission.roomId, reason: outcome.reason });
|
|
421
|
+
if (outcome.reason === 'rate_limited')
|
|
422
|
+
refuse('rate/limited', 'reaction rate limit');
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
nsp.to(roomChannel(c.admission.roomId)).emit('chat_reaction', outcome.payload);
|
|
426
|
+
});
|
|
427
|
+
// Relayed, never stored. A `true` is relayed at most once a second per
|
|
428
|
+
// connection (the client repeats it every few seconds while typing, and a
|
|
429
|
+
// listener expires it if the repeats stop); a change of state always is.
|
|
430
|
+
socket.on('chat_typing', (payload) => {
|
|
431
|
+
const c = conns.get(socket.id);
|
|
432
|
+
const typing = parseChatTyping(payload);
|
|
433
|
+
if (!c || typing === null)
|
|
434
|
+
return;
|
|
435
|
+
const now = Date.now();
|
|
436
|
+
if (typing && c.typing && c.typingAt !== undefined && now - c.typingAt < TYPING_RELAY_MIN_MS)
|
|
437
|
+
return;
|
|
438
|
+
if (!typing && !c.typing)
|
|
439
|
+
return;
|
|
440
|
+
if (typing)
|
|
441
|
+
c.typingAt = now;
|
|
442
|
+
relayTyping(c, typing);
|
|
443
|
+
});
|
|
395
444
|
socket.on('disconnect', (reason) => {
|
|
396
445
|
joining.delete(socket.id);
|
|
397
446
|
const c = conns.get(socket.id);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/rooms-server",
|
|
3
|
-
"version": "0.45.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.45.102",
|
|
4
|
+
"gitHead": "1673b2ed872651f846cfab778b5de8639ef490ea",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Room lifecycle, membership, seating, identity, presence, backpressure-aware emit and durable room storage for a socket.io server.",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"directory": "packages/rooms-server"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@0.45.
|
|
38
|
+
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@0.45.102"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"socket.io": "^4.8.3"
|