chirkle 0.0.0-stage → 0.1.0

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.
Files changed (137) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +310 -2
  3. package/package.json +75 -4
  4. package/pb_hooks/federation/config.js +276 -0
  5. package/pb_hooks/federation/inbox.js +316 -0
  6. package/pb_hooks/federation/messages.js +420 -0
  7. package/pb_hooks/federation/mirror.js +277 -0
  8. package/pb_hooks/federation/net.js +247 -0
  9. package/pb_hooks/federation/peers.js +490 -0
  10. package/pb_hooks/federation/people.js +376 -0
  11. package/pb_hooks/federation/rooms.js +552 -0
  12. package/pb_hooks/federation/worker.js +413 -0
  13. package/pb_hooks/federation.pb.js +141 -0
  14. package/pb_hooks/lib/access.js +102 -0
  15. package/pb_hooks/lib/account.js +31 -0
  16. package/pb_hooks/lib/anonymous.js +189 -0
  17. package/pb_hooks/lib/bulk.js +187 -0
  18. package/pb_hooks/lib/collections.js +587 -0
  19. package/pb_hooks/lib/dms.js +123 -0
  20. package/pb_hooks/lib/emoji.js +28 -0
  21. package/pb_hooks/lib/enrich.js +75 -0
  22. package/pb_hooks/lib/features.js +31 -0
  23. package/pb_hooks/lib/files.js +375 -0
  24. package/pb_hooks/lib/http.js +146 -0
  25. package/pb_hooks/lib/images.js +160 -0
  26. package/pb_hooks/lib/keepalive.js +31 -0
  27. package/pb_hooks/lib/lists.js +173 -0
  28. package/pb_hooks/lib/media.js +635 -0
  29. package/pb_hooks/lib/messages.js +519 -0
  30. package/pb_hooks/lib/moderation.js +128 -0
  31. package/pb_hooks/lib/outbound.js +116 -0
  32. package/pb_hooks/lib/pages.js +171 -0
  33. package/pb_hooks/lib/previews.js +346 -0
  34. package/pb_hooks/lib/reactions.js +110 -0
  35. package/pb_hooks/lib/reads.js +181 -0
  36. package/pb_hooks/lib/records.js +77 -0
  37. package/pb_hooks/lib/rooms.js +148 -0
  38. package/pb_hooks/lib/site.js +102 -0
  39. package/pb_hooks/lib/text.js +110 -0
  40. package/pb_hooks/lib/users.js +81 -0
  41. package/pb_hooks/lib/worker.js +159 -0
  42. package/pb_hooks/main.pb.js +324 -0
  43. package/pb_hooks/telegram/api.js +128 -0
  44. package/pb_hooks/telegram/inbound.js +548 -0
  45. package/pb_hooks/telegram/links.js +157 -0
  46. package/pb_hooks/telegram/outbound.js +323 -0
  47. package/pb_hooks/telegram/people.js +166 -0
  48. package/pb_hooks/telegram/rich.js +192 -0
  49. package/pb_hooks/telegram/worker.js +181 -0
  50. package/pb_hooks/telegram.pb.js +47 -0
  51. package/pb_migrations/1760000000_init.js +150 -0
  52. package/pb_migrations/1760000001_qa_fixes.js +69 -0
  53. package/pb_migrations/1760000002_avatars.js +39 -0
  54. package/pb_migrations/1760000003_direct_messages.js +142 -0
  55. package/pb_migrations/1760000004_attachments.js +28 -0
  56. package/pb_migrations/1760000005_file_names.js +16 -0
  57. package/pb_migrations/1760000006_room_reads.js +41 -0
  58. package/pb_migrations/1760000007_replies.js +23 -0
  59. package/pb_migrations/1760000008_lowercase_emails.js +24 -0
  60. package/pb_migrations/1760000009_reactions.js +32 -0
  61. package/pb_migrations/1760000010_fit_thumbs.js +18 -0
  62. package/pb_migrations/1760000011_forwarding.js +39 -0
  63. package/pb_migrations/1760000012_accounts.js +55 -0
  64. package/pb_migrations/1760000013_qa_pass5.js +19 -0
  65. package/pb_migrations/1760000014_room_access.js +96 -0
  66. package/pb_migrations/1760000015_site.js +46 -0
  67. package/pb_migrations/1760000016_forward_refs.js +43 -0
  68. package/pb_migrations/1760000017_no_dms.js +18 -0
  69. package/pb_migrations/1760000018_attachment_limits.js +24 -0
  70. package/pb_migrations/1760000019_telegram.js +109 -0
  71. package/pb_migrations/1760000020_service_messages.js +21 -0
  72. package/pb_migrations/1760000021_forward_view_index.js +41 -0
  73. package/pb_migrations/1760000022_link_previews.js +43 -0
  74. package/pb_migrations/1760000023_room_writers.js +49 -0
  75. package/pb_migrations/1760000024_message_search.js +51 -0
  76. package/pb_migrations/1760000025_search_dotted_i.js +16 -0
  77. package/pb_migrations/1760000026_push.js +67 -0
  78. package/pb_migrations/1760000027_push_tokens_per_user.js +31 -0
  79. package/pb_migrations/1760000028_media_grid_thumbs.js +18 -0
  80. package/pb_migrations/1760000029_media.js +71 -0
  81. package/pb_migrations/1760000030_collections.js +140 -0
  82. package/pb_migrations/1760000031_unread_limit.js +20 -0
  83. package/pb_migrations/1760000032_federation.js +227 -0
  84. package/pb_migrations/1760000033_federation_requests.js +44 -0
  85. package/pb_migrations/1760000034_telegram_parts.js +26 -0
  86. package/pb_migrations/1760000035_telegram_anonymous.js +16 -0
  87. package/pb_migrations/1760000036_chirkle.js +20 -0
  88. package/pb_migrations/1760000037_file_dims.js +35 -0
  89. package/pb_migrations/1760000038_drop_push.js +64 -0
  90. package/pb_migrations/1760000039_anonymous_rooms.js +40 -0
  91. package/pb_migrations/1760000040_moderators.js +42 -0
  92. package/pb_migrations/1760000041_shared_files.js +500 -0
  93. package/pb_migrations/1760000042_files_src.js +17 -0
  94. package/pb_public/assets/access-ALBW2MT2.js +2 -0
  95. package/pb_public/assets/access-ALBW2MT2.js.map +7 -0
  96. package/pb_public/assets/access-PB77EH4F.css +2 -0
  97. package/pb_public/assets/access-PB77EH4F.css.map +7 -0
  98. package/pb_public/assets/app-ECR34OBK.css +2 -0
  99. package/pb_public/assets/app-ECR34OBK.css.map +7 -0
  100. package/pb_public/assets/app-SILEBEXB.js +3 -0
  101. package/pb_public/assets/app-SILEBEXB.js.map +7 -0
  102. package/pb_public/assets/collections-VEOIOCAW.css +2 -0
  103. package/pb_public/assets/collections-VEOIOCAW.css.map +7 -0
  104. package/pb_public/assets/emoji-WSTVXAW5.css +2 -0
  105. package/pb_public/assets/emoji-WSTVXAW5.css.map +7 -0
  106. package/pb_public/assets/emoji-picker-QYRX6NYL.js +609 -0
  107. package/pb_public/assets/emoji-picker-QYRX6NYL.js.map +7 -0
  108. package/pb_public/assets/inter-cyrillic-JEOLYBOO.woff2 +0 -0
  109. package/pb_public/assets/inter-cyrillic-ext-IYF56FF6.woff2 +0 -0
  110. package/pb_public/assets/inter-greek-IRE366VL.woff2 +0 -0
  111. package/pb_public/assets/inter-latin-NRMW37G5.woff2 +0 -0
  112. package/pb_public/assets/inter-latin-ext-HA22NDSG.woff2 +0 -0
  113. package/pb_public/assets/lazy-SCCVSUZO.js +2 -0
  114. package/pb_public/assets/lazy-SCCVSUZO.js.map +7 -0
  115. package/pb_public/assets/media-DH7ECZSF.js +2 -0
  116. package/pb_public/assets/media-DH7ECZSF.js.map +7 -0
  117. package/pb_public/assets/media-L3EYTHKT.css +2 -0
  118. package/pb_public/assets/media-L3EYTHKT.css.map +7 -0
  119. package/pb_public/assets/notify-L6GERFNO.js +2 -0
  120. package/pb_public/assets/notify-L6GERFNO.js.map +7 -0
  121. package/pb_public/assets/search-3UT4HMES.js +2 -0
  122. package/pb_public/assets/search-3UT4HMES.js.map +7 -0
  123. package/pb_public/assets/switcher-CEUKRLEY.js +2 -0
  124. package/pb_public/assets/switcher-CEUKRLEY.js.map +7 -0
  125. package/pb_public/assets/viewer-DXT7SKOU.js +2 -0
  126. package/pb_public/assets/viewer-DXT7SKOU.js.map +7 -0
  127. package/pb_public/assets/viewer-P7GYCBYM.css +2 -0
  128. package/pb_public/assets/viewer-P7GYCBYM.css.map +7 -0
  129. package/pb_public/icons/apple-touch-icon.png +0 -0
  130. package/pb_public/icons/icon-192.png +0 -0
  131. package/pb_public/icons/icon-512.png +0 -0
  132. package/pb_public/icons/icon.svg +1 -0
  133. package/pb_public/icons/maskable-512.png +0 -0
  134. package/pb_public/index.html +21 -0
  135. package/pb_public/sw.js +1 -0
  136. package/scripts/fetch-pocketbase.sh +63 -0
  137. package/scripts/start.mjs +93 -0
@@ -0,0 +1,376 @@
1
+ /// <reference path="../../types/pocketbase.d.ts" />
2
+ // People from other instances (DESIGN.md §33.4): each gets a stand-in user ("Ann (B)") that their messages, reactions
3
+ // and memberships show under, as Telegram senders do (§26.3). fed_people says who a stand-in is (peer, global id); it
4
+ // also lists which of this instance's own people a peer has been told of ("known"), who it hears from again when their
5
+ // name, picture or DM setting changes.
6
+ //
7
+ // Events name people by global id and carry their profiles ({ name, no_dms, avatar, path }), so a receiver can make
8
+ // the stand-ins it needs. A peer vouches for its own people, and the home for the people of a third instance it shares
9
+ // a room with (§33.4): those are labelled with their host and take no DMs here.
10
+
11
+ const { fieldError } = require(`${__hooks}/lib/records.js`);
12
+ const { nameKey, tidy } = require(`${__hooks}/lib/text.js`);
13
+ const { enqueue, enqueueWork, gid, isActive, myHost, newId, peerByHost, peerHost, splitGid } = require(`${__hooks}/federation/config.js`);
14
+
15
+ /** users.name max. */
16
+ const NAME_MAX = 32;
17
+ /** The label of a third instance's people: their host, cut. */
18
+ const HOST_LABEL_MAX = 12;
19
+
20
+ /**
21
+ * @typedef {{ name: string, no_dms: boolean, avatar: string, path: string }} Profile `avatar` names the picture (a new
22
+ * one has a new name, "" for none); `path` is where the sender serves it.
23
+ */
24
+
25
+ /**
26
+ * "Ann (B)", or "Ann 2 (B)" when that is taken (names are unique, §22.1), within users.name's 32.
27
+ * @param {string} name
28
+ * @param {string} label
29
+ * @param {number} n
30
+ */
31
+ function displayName(name, label, n) {
32
+ const tail = `${n > 1 ? ` ${n}` : ""} (${label})`;
33
+ const base =
34
+ [...tidy(name)]
35
+ .slice(0, NAME_MAX - tail.length)
36
+ .join("")
37
+ .trim() || "Someone";
38
+ return `${base}${tail}`;
39
+ }
40
+
41
+ /**
42
+ * Save `user` with the first free display name for `name`.
43
+ * @param {core.App} app
44
+ * @param {core.Record} user
45
+ * @param {string} name
46
+ * @param {string} label
47
+ */
48
+ function saveWithName(app, user, name, label) {
49
+ for (let n = 1; n < 1000; n++) {
50
+ const candidate = displayName(name, label, n);
51
+ if (candidate === user.getString("name")) return app.save(user);
52
+ try {
53
+ app.findFirstRecordByFilter("users", "name_key = {:key} && id != {:id}", { key: nameKey(candidate), id: user.id });
54
+ continue; // taken
55
+ } catch {
56
+ // free
57
+ }
58
+ user.set("name", candidate);
59
+ app.save(user);
60
+ return;
61
+ }
62
+ throw new Error("no free display name");
63
+ }
64
+
65
+ /**
66
+ * The fed_people row of a stand-in user, or null for anyone else.
67
+ * @param {core.App} app
68
+ * @param {string} userId
69
+ */
70
+ function standInRow(app, userId) {
71
+ if (!userId) return null;
72
+ try {
73
+ return app.findFirstRecordByFilter("fed_people", "user = {:u} && kind = 'standin'", { u: userId });
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * The stand-in row for a person, looked up under the peer that speaks for them: their own instance when it is paired
81
+ * here, else the instance that told of them (the home of a room they are in, §33.4).
82
+ * @param {core.App} app
83
+ * @param {core.Record} sender
84
+ * @param {string} g
85
+ */
86
+ function rowOf(app, sender, g) {
87
+ const host = splitGid(g)?.host ?? "";
88
+ const own = host === peerHost(sender) ? sender : peerByHost(app, host);
89
+ for (const p of own && own.id !== sender.id ? [own, sender] : [sender]) {
90
+ try {
91
+ return { row: app.findFirstRecordByFilter("fed_people", "peer = {:p} && remote = {:g}", { p: p.id, g }), peer: p };
92
+ } catch {
93
+ // not under this one
94
+ }
95
+ }
96
+ return { row: null, peer: own && isActive(own) ? own : sender };
97
+ }
98
+
99
+ /**
100
+ * The DM setting a stand-in has here: their own, unless DMs with them can't happen (§33.5): their instance didn't tick
101
+ * `dms` here, isn't paired any more, or isn't the one vouching for them.
102
+ * @param {core.Record} peer
103
+ * @param {string} g
104
+ * @param {boolean} theirs
105
+ */
106
+ const noDmsHere = (peer, g, theirs) => theirs || !peer.getBool("dms") || !isActive(peer) || splitGid(g)?.host !== peerHost(peer);
107
+
108
+ /**
109
+ * The label a stand-in's name ends in: their peer's, or for a vouched-for person their host, cut.
110
+ * @param {core.Record} peer
111
+ * @param {string} g
112
+ */
113
+ function labelOf(peer, g) {
114
+ const host = splitGid(g)?.host ?? "";
115
+ return host === peerHost(peer) ? peer.getString("label") : host.slice(0, HOST_LABEL_MAX);
116
+ }
117
+
118
+ /**
119
+ * Bring a stand-in up to date with what its own speaker says: its name, DM setting and picture (fetched later).
120
+ * @param {core.App} app
121
+ * @param {core.Record} row
122
+ * @param {core.Record} peer
123
+ * @param {Profile} p
124
+ */
125
+ function applyProfile(app, row, peer, p) {
126
+ const g = row.getString("remote");
127
+ const user = app.findRecordById("users", row.getString("user"));
128
+ const name = String(p.name || "").slice(0, 255);
129
+ const noDms = !!p.no_dms;
130
+ if (name && name !== row.getString("name")) {
131
+ row.set("name", name);
132
+ saveWithName(app, user, name, labelOf(peer, g));
133
+ }
134
+ const want = noDmsHere(peer, g, noDms);
135
+ if (row.getBool("no_dms") !== noDms || user.getBool("no_dms") !== want) {
136
+ row.set("no_dms", noDms);
137
+ user.set("no_dms", want);
138
+ app.save(user);
139
+ }
140
+ const avatar = String(p.avatar || "").slice(0, 255);
141
+ if (avatar !== row.getString("avatar")) {
142
+ row.set("avatar", avatar);
143
+ if (!avatar) {
144
+ user.set("avatar", null);
145
+ app.save(user);
146
+ } else if (typeof p.path === "string" && p.path.startsWith("/api/fed/avatars/")) {
147
+ enqueueWork(app, peer.id, "avatar", { user: user.id, path: p.path, key: avatar });
148
+ }
149
+ }
150
+ app.save(row);
151
+ }
152
+
153
+ /**
154
+ * The local user a global id stands for, made when it is a new stand-in and its profile came with the event.
155
+ * One of this instance's own ids is that user (who must exist and be no one's stand-in). "" when unknown.
156
+ * @param {core.App} app
157
+ * @param {core.Record} sender the peer the event came from
158
+ * @param {unknown} g
159
+ * @param {Record<string, Profile>} [people] the event's profiles
160
+ * @param {boolean} [own] only the sender's own people (what a mirror may name, §33.6)
161
+ */
162
+ function userOf(app, sender, g, people = {}, own = false) {
163
+ const s = splitGid(g);
164
+ if (!s) return "";
165
+ const key = /** @type {string} */ (g);
166
+ if (own && s.host !== peerHost(sender)) return "";
167
+ if (s.host === myHost()) {
168
+ try {
169
+ const u = app.findRecordById("users", s.id);
170
+ return standInRow(app, u.id) ? "" : u.id;
171
+ } catch {
172
+ return "";
173
+ }
174
+ }
175
+ const { row, peer } = rowOf(app, sender, key);
176
+ const profile = people && typeof people === "object" ? people[key] : undefined;
177
+ if (row) {
178
+ // Only who speaks for them changes them: a home relaying a third instance's person doesn't, once that instance does.
179
+ if (profile && row.getString("peer") === sender.id) applyProfile(app, row, sender, profile);
180
+ return row.getString("user");
181
+ }
182
+ if (!profile || typeof profile.name !== "string") return "";
183
+ const user = new Record(app.findCollectionByNameOrId("users"));
184
+ user.set("email", `fed${newId()}@federation.invalid`);
185
+ user.setPassword($security.randomString(40));
186
+ user.set("peer", peer.id);
187
+ user.set("instance", s.host);
188
+ user.set("no_dms", true);
189
+ saveWithName(app, user, profile.name, labelOf(peer, key));
190
+ const made = new Record(app.findCollectionByNameOrId("fed_people"));
191
+ made.set("peer", peer.id);
192
+ made.set("remote", key);
193
+ made.set("user", user.id);
194
+ made.set("kind", "standin");
195
+ made.set("name", "");
196
+ try {
197
+ app.save(made);
198
+ } catch (err) {
199
+ // Made meanwhile by another delivery (the unique index): use that one.
200
+ app.delete(user);
201
+ const again = rowOf(app, sender, key).row;
202
+ if (!again) throw err;
203
+ return again.getString("user");
204
+ }
205
+ applyProfile(app, made, peer, profile);
206
+ return user.id;
207
+ }
208
+
209
+ /**
210
+ * The global id of a local user: a stand-in's, or this instance's own.
211
+ * @param {core.App} app
212
+ * @param {string} userId
213
+ */
214
+ function gidOf(app, userId) {
215
+ const row = standInRow(app, userId);
216
+ return row ? row.getString("remote") : gid(userId);
217
+ }
218
+
219
+ /**
220
+ * What a peer is told of a person (§33.4): their own name (a stand-in's as their instance says it), DM setting and
221
+ * picture, which the peer fetches from here.
222
+ * @param {core.App} app
223
+ * @param {string} userId
224
+ * @returns {Profile | null}
225
+ */
226
+ function profileOf(app, userId) {
227
+ let user;
228
+ try {
229
+ user = app.findRecordById("users", userId);
230
+ } catch {
231
+ return null;
232
+ }
233
+ const row = standInRow(app, userId);
234
+ const avatar = user.getString("avatar");
235
+ return {
236
+ name: row ? row.getString("name") || user.getString("name") : user.getString("name"),
237
+ no_dms: row ? row.getBool("no_dms") : user.getBool("no_dms"),
238
+ avatar: row ? (avatar ? row.getString("avatar") : "") : avatar,
239
+ path: `/api/fed/avatars/${user.id}`,
240
+ };
241
+ }
242
+
243
+ /**
244
+ * The profiles of these users, by global id, for an event to `peer`. Its own people need none: it has them. This
245
+ * instance's own people are noted as known to the peer, which then hears of their changes.
246
+ * @param {core.App} app
247
+ * @param {core.Record} peer
248
+ * @param {string[]} userIds
249
+ */
250
+ function peopleFor(app, peer, userIds) {
251
+ /** @type {Record<string, Profile>} */
252
+ const out = {};
253
+ for (const id of new Set(userIds.filter(Boolean))) {
254
+ const g = gidOf(app, id);
255
+ if (splitGid(g)?.host === peerHost(peer)) continue;
256
+ const p = profileOf(app, id);
257
+ if (!p) continue;
258
+ out[g] = p;
259
+ remember(app, peer, id, g);
260
+ }
261
+ return out;
262
+ }
263
+
264
+ /**
265
+ * Note that `peer` has been told of local user `userId` (one of ours, or a stand-in it doesn't own).
266
+ * @param {core.App} app
267
+ * @param {core.Record} peer
268
+ * @param {string} userId
269
+ * @param {string} g
270
+ */
271
+ function remember(app, peer, userId, g) {
272
+ try {
273
+ app.findFirstRecordByFilter("fed_people", "peer = {:p} && remote = {:g}", { p: peer.id, g });
274
+ return;
275
+ } catch {
276
+ // not yet
277
+ }
278
+ const row = new Record(app.findCollectionByNameOrId("fed_people"));
279
+ row.set("peer", peer.id);
280
+ row.set("remote", g);
281
+ row.set("user", userId);
282
+ row.set("kind", "known");
283
+ try {
284
+ app.save(row);
285
+ } catch {
286
+ // noted meanwhile
287
+ }
288
+ }
289
+
290
+ /** What peers are told of a user, to compare before and after a save. @param {core.Record} u */
291
+ const profileKey = (u) => ["name", "avatar", "no_dms"].map((f) => u.getString(f)).join("|");
292
+
293
+ /**
294
+ * users update (saved): a person whose name, picture or DM setting changed is told of to the peers that know them
295
+ * (a `user` event), but not to the one they are from.
296
+ * @param {core.App} app
297
+ * @param {core.Record} user
298
+ * @param {string} before profileKey before
299
+ */
300
+ function userChanged(app, user, before) {
301
+ if (profileKey(user) === before) return;
302
+ const g = gidOf(app, user.id);
303
+ const p = profileOf(app, user.id);
304
+ if (!p) return;
305
+ for (const row of app.findRecordsByFilter("fed_people", "user = {:u} && kind = 'known'", "", 0, 0, { u: user.id })) {
306
+ if (row) enqueue(app, row.getString("peer"), { type: "user", person: g, profile: p });
307
+ }
308
+ }
309
+
310
+ /**
311
+ * A `user` event: a peer's person changed. Only their own instance, or whoever vouches for them here, says so.
312
+ * @param {core.App} app
313
+ * @param {core.Record} sender
314
+ * @param {any} ev
315
+ */
316
+ function applyUser(app, sender, ev) {
317
+ const g = String(ev.person || "");
318
+ const { row } = rowOf(app, sender, g);
319
+ if (!row || row.getString("peer") !== sender.id || row.getString("kind") !== "standin") return; // not one we have
320
+ if (ev.profile && typeof ev.profile === "object") applyProfile(app, row, sender, ev.profile);
321
+ }
322
+
323
+ /**
324
+ * After a peer's `dms` or status changed (§33.5, §33.7): its stand-ins take DMs, or not.
325
+ * @param {core.App} app
326
+ * @param {core.Record} peer
327
+ */
328
+ function refreshDms(app, peer) {
329
+ for (const row of app.findRecordsByFilter("fed_people", "peer = {:p} && kind = 'standin'", "", 0, 0, { p: peer.id })) {
330
+ if (!row) continue;
331
+ try {
332
+ const user = app.findRecordById("users", row.getString("user"));
333
+ const want = noDmsHere(peer, row.getString("remote"), row.getBool("no_dms"));
334
+ if (user.getBool("no_dms") !== want) {
335
+ user.set("no_dms", want);
336
+ app.save(user);
337
+ }
338
+ } catch {
339
+ // gone
340
+ }
341
+ }
342
+ }
343
+
344
+ /**
345
+ * users create/update request: names ending in a peer's label, " (B)" however written, are its people's while it is
346
+ * paired (§33.4). Superusers name anyone.
347
+ * @param {core.RecordRequestEvent} e
348
+ */
349
+ function refuseLabelName(e) {
350
+ const rec = e.record;
351
+ if (!rec || e.hasSuperuserAuth()) return;
352
+ const name = rec.getString("name");
353
+ if (!rec.isNew() && name === rec.original().getString("name")) return;
354
+ const key = nameKey(tidy(name)).replace(/\s+/g, "");
355
+ for (const p of e.app.findRecordsByFilter("fed_peers", "", "", 0, 0)) {
356
+ if (!p) continue;
357
+ const label = p.getString("label");
358
+ if (label && key.endsWith(nameKey(`(${label})`).replace(/\s+/g, ""))) {
359
+ throw fieldError("name", `Names ending in (${label}) are for people on ${peerHost(p)}. Choose another one.`);
360
+ }
361
+ }
362
+ }
363
+
364
+ module.exports = {
365
+ userOf,
366
+ gidOf,
367
+ standInRow,
368
+ profileOf,
369
+ peopleFor,
370
+ profileKey,
371
+ userChanged,
372
+ applyUser,
373
+ refreshDms,
374
+ refuseLabelName,
375
+ displayName,
376
+ };