chirkle 0.4.1 → 0.5.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 (204) hide show
  1. package/README.md +35 -201
  2. package/bin/release/darwin-amd64/chirkle-server +2 -2
  3. package/bin/release/darwin-arm64/chirkle-server +0 -0
  4. package/bin/release/linux-amd64/chirkle-server +0 -0
  5. package/bin/release/linux-arm64/chirkle-server +0 -0
  6. package/package.json +17 -5
  7. package/pb_hooks/lib/collections.js +5 -3
  8. package/pb_hooks/lib/handles.js +24 -2
  9. package/pb_hooks/lib/http.js +2 -2
  10. package/pb_hooks/lib/inbox.js +6 -5
  11. package/pb_hooks/lib/media.js +2 -2
  12. package/pb_hooks/lib/users.js +33 -2
  13. package/pb_hooks/main.pb.js +1 -0
  14. package/pb_hooks/telegram/inbound.js +5 -0
  15. package/pb_hooks/telegram/links.js +12 -1
  16. package/pb_hooks/telegram/outbound.js +56 -2
  17. package/pb_hooks/telegram/worker.js +2 -1
  18. package/pb_migrations/1760000057_reactions_seen.js +17 -0
  19. package/pb_migrations/1760000058_users_kind_public.js +20 -0
  20. package/pb_public/assets/{access-UK3L54NR.js → access-KVSI7EFH.js} +2 -2
  21. package/pb_public/assets/access-KVSI7EFH.js.br +0 -0
  22. package/pb_public/assets/access-KVSI7EFH.js.gz +0 -0
  23. package/pb_public/assets/access-XGNXIUR5.css +2 -0
  24. package/pb_public/assets/access-XGNXIUR5.css.br +0 -0
  25. package/pb_public/assets/access-XGNXIUR5.css.gz +0 -0
  26. package/pb_public/assets/access-XGNXIUR5.css.map +7 -0
  27. package/pb_public/assets/account-EBCPOLWT.css +2 -0
  28. package/pb_public/assets/account-EBCPOLWT.css.br +0 -0
  29. package/pb_public/assets/account-EBCPOLWT.css.gz +0 -0
  30. package/pb_public/assets/account-EBCPOLWT.css.map +7 -0
  31. package/pb_public/assets/account-api-J6A6IYVX.js.br +0 -0
  32. package/pb_public/assets/account-api-J6A6IYVX.js.gz +0 -0
  33. package/pb_public/assets/app-5JOOV6JX.js +3 -0
  34. package/pb_public/assets/app-5JOOV6JX.js.br +0 -0
  35. package/pb_public/assets/app-5JOOV6JX.js.gz +0 -0
  36. package/pb_public/assets/app-5JOOV6JX.js.map +7 -0
  37. package/pb_public/assets/app-7OMYYLCI.css +2 -0
  38. package/pb_public/assets/app-7OMYYLCI.css.br +0 -0
  39. package/pb_public/assets/app-7OMYYLCI.css.gz +0 -0
  40. package/pb_public/assets/app-7OMYYLCI.css.map +7 -0
  41. package/pb_public/assets/chunk-5PKDEWJS.js +2 -0
  42. package/pb_public/assets/chunk-5PKDEWJS.js.br +0 -0
  43. package/pb_public/assets/chunk-5PKDEWJS.js.gz +0 -0
  44. package/pb_public/assets/chunk-5PKDEWJS.js.map +7 -0
  45. package/pb_public/assets/chunk-AG73QNUN.js.br +0 -0
  46. package/pb_public/assets/chunk-AG73QNUN.js.gz +0 -0
  47. package/pb_public/assets/chunk-DCLJRQ53.js.br +0 -0
  48. package/pb_public/assets/chunk-DCLJRQ53.js.gz +0 -0
  49. package/pb_public/assets/chunk-EO3AMXJN.js +2 -0
  50. package/pb_public/assets/chunk-EO3AMXJN.js.br +0 -0
  51. package/pb_public/assets/chunk-EO3AMXJN.js.gz +0 -0
  52. package/pb_public/assets/chunk-EO3AMXJN.js.map +7 -0
  53. package/pb_public/assets/chunk-LDZPNZ2E.js +2 -0
  54. package/pb_public/assets/chunk-LDZPNZ2E.js.br +0 -0
  55. package/pb_public/assets/chunk-LDZPNZ2E.js.gz +0 -0
  56. package/pb_public/assets/chunk-LDZPNZ2E.js.map +7 -0
  57. package/pb_public/assets/chunk-RPCBA7VF.js.br +0 -0
  58. package/pb_public/assets/chunk-RPCBA7VF.js.gz +0 -0
  59. package/pb_public/assets/chunk-RYZHXNLF.js +2 -0
  60. package/pb_public/assets/chunk-RYZHXNLF.js.br +0 -0
  61. package/pb_public/assets/chunk-RYZHXNLF.js.gz +0 -0
  62. package/pb_public/assets/chunk-RYZHXNLF.js.map +7 -0
  63. package/pb_public/assets/chunk-UZDXAORM.js.br +0 -0
  64. package/pb_public/assets/chunk-UZDXAORM.js.gz +0 -0
  65. package/pb_public/assets/chunk-VSHXXDW4.js +2 -0
  66. package/pb_public/assets/chunk-VSHXXDW4.js.br +0 -0
  67. package/pb_public/assets/chunk-VSHXXDW4.js.gz +0 -0
  68. package/pb_public/assets/chunk-VSHXXDW4.js.map +7 -0
  69. package/pb_public/assets/chunk-VTOUI25E.js.br +0 -0
  70. package/pb_public/assets/chunk-VTOUI25E.js.gz +0 -0
  71. package/pb_public/assets/{chunk-DZC4SY4M.js → chunk-Y5MCBN66.js} +2 -2
  72. package/pb_public/assets/chunk-Y5MCBN66.js.br +0 -0
  73. package/pb_public/assets/chunk-Y5MCBN66.js.gz +0 -0
  74. package/pb_public/assets/{chunk-DZC4SY4M.js.map → chunk-Y5MCBN66.js.map} +3 -3
  75. package/pb_public/assets/collections-FZB6G4W4.css +2 -0
  76. package/pb_public/assets/collections-FZB6G4W4.css.br +0 -0
  77. package/pb_public/assets/collections-FZB6G4W4.css.gz +0 -0
  78. package/pb_public/assets/collections-FZB6G4W4.css.map +7 -0
  79. package/pb_public/assets/emoji-IHRUMGCY.css +2 -0
  80. package/pb_public/assets/emoji-IHRUMGCY.css.br +0 -0
  81. package/pb_public/assets/emoji-IHRUMGCY.css.gz +0 -0
  82. package/pb_public/assets/emoji-IHRUMGCY.css.map +7 -0
  83. package/pb_public/assets/{emoji-picker-K6JTK2GV.js → emoji-picker-W27IJER2.js} +2 -2
  84. package/pb_public/assets/emoji-picker-W27IJER2.js.br +0 -0
  85. package/pb_public/assets/emoji-picker-W27IJER2.js.gz +0 -0
  86. package/pb_public/assets/{forward-267HRNPY.js → forward-5TJEYGEV.js} +2 -2
  87. package/pb_public/assets/forward-5TJEYGEV.js.br +0 -0
  88. package/pb_public/assets/forward-5TJEYGEV.js.gz +0 -0
  89. package/pb_public/assets/inbox-2AXY3INA.css +2 -0
  90. package/pb_public/assets/inbox-2AXY3INA.css.br +0 -0
  91. package/pb_public/assets/inbox-2AXY3INA.css.gz +0 -0
  92. package/pb_public/assets/inbox-2AXY3INA.css.map +7 -0
  93. package/pb_public/assets/{inbox-CLMYESNI.js → inbox-A46J7ZU2.js} +2 -2
  94. package/pb_public/assets/inbox-A46J7ZU2.js.br +0 -0
  95. package/pb_public/assets/inbox-A46J7ZU2.js.gz +0 -0
  96. package/pb_public/assets/{inbox-CLMYESNI.js.map → inbox-A46J7ZU2.js.map} +2 -2
  97. package/pb_public/assets/{invite-OGT5E2MZ.js → invite-6BCBF4KV.js} +2 -2
  98. package/pb_public/assets/invite-6BCBF4KV.js.br +0 -0
  99. package/pb_public/assets/invite-6BCBF4KV.js.gz +0 -0
  100. package/pb_public/assets/invite-api-7G7XPXQW.js.br +0 -0
  101. package/pb_public/assets/invite-api-7G7XPXQW.js.gz +0 -0
  102. package/pb_public/assets/lazy-OVEJT5CP.js +2 -0
  103. package/pb_public/assets/lazy-OVEJT5CP.js.br +0 -0
  104. package/pb_public/assets/lazy-OVEJT5CP.js.gz +0 -0
  105. package/pb_public/assets/lazy-OVEJT5CP.js.map +7 -0
  106. package/pb_public/assets/{login-TK6K4WGB.js → login-FZY6GOMF.js} +2 -2
  107. package/pb_public/assets/login-FZY6GOMF.js.br +0 -0
  108. package/pb_public/assets/login-FZY6GOMF.js.gz +0 -0
  109. package/pb_public/assets/media-BCKZQR2R.css +2 -0
  110. package/pb_public/assets/media-BCKZQR2R.css.br +0 -0
  111. package/pb_public/assets/media-BCKZQR2R.css.gz +0 -0
  112. package/pb_public/assets/media-BCKZQR2R.css.map +7 -0
  113. package/pb_public/assets/{media-WZ4653L5.js → media-VCJWBQJZ.js} +2 -2
  114. package/pb_public/assets/media-VCJWBQJZ.js.br +0 -0
  115. package/pb_public/assets/media-VCJWBQJZ.js.gz +0 -0
  116. package/pb_public/assets/{mention-suggest-ODJD2IC5.js → mention-suggest-K3UUHR4D.js} +2 -2
  117. package/pb_public/assets/mention-suggest-K3UUHR4D.js.br +0 -0
  118. package/pb_public/assets/mention-suggest-K3UUHR4D.js.gz +0 -0
  119. package/pb_public/assets/notify-EPDM772N.js.br +0 -0
  120. package/pb_public/assets/notify-EPDM772N.js.gz +0 -0
  121. package/pb_public/assets/profile-7KMXLX5U.js +2 -0
  122. package/pb_public/assets/profile-7KMXLX5U.js.br +0 -0
  123. package/pb_public/assets/profile-7KMXLX5U.js.gz +0 -0
  124. package/pb_public/assets/profile-7KMXLX5U.js.map +7 -0
  125. package/pb_public/assets/rooms-forms-IADHTHBZ.js +2 -0
  126. package/pb_public/assets/rooms-forms-IADHTHBZ.js.br +0 -0
  127. package/pb_public/assets/rooms-forms-IADHTHBZ.js.gz +0 -0
  128. package/pb_public/assets/rooms-forms-IADHTHBZ.js.map +7 -0
  129. package/pb_public/assets/search-HOPAWIMQ.js +2 -0
  130. package/pb_public/assets/search-HOPAWIMQ.js.br +0 -0
  131. package/pb_public/assets/search-HOPAWIMQ.js.gz +0 -0
  132. package/pb_public/assets/search-HOPAWIMQ.js.map +7 -0
  133. package/pb_public/assets/sidebar-forms-ETSRVSPY.css +2 -0
  134. package/pb_public/assets/sidebar-forms-ETSRVSPY.css.br +0 -0
  135. package/pb_public/assets/sidebar-forms-ETSRVSPY.css.gz +0 -0
  136. package/pb_public/assets/sidebar-forms-ETSRVSPY.css.map +7 -0
  137. package/pb_public/assets/stats-5GSWDHZI.css +2 -0
  138. package/pb_public/assets/stats-5GSWDHZI.css.br +0 -0
  139. package/pb_public/assets/stats-5GSWDHZI.css.gz +0 -0
  140. package/pb_public/assets/stats-5GSWDHZI.css.map +7 -0
  141. package/pb_public/assets/{stats-GTO2H6PG.js → stats-Y3LIXAZR.js} +2 -2
  142. package/pb_public/assets/stats-Y3LIXAZR.js.br +0 -0
  143. package/pb_public/assets/stats-Y3LIXAZR.js.gz +0 -0
  144. package/pb_public/assets/stats-Y3LIXAZR.js.map +7 -0
  145. package/pb_public/assets/switcher-TFSO45KV.js.br +0 -0
  146. package/pb_public/assets/switcher-TFSO45KV.js.gz +0 -0
  147. package/pb_public/assets/user-search-GUNMIBSB.js +2 -0
  148. package/pb_public/assets/user-search-GUNMIBSB.js.br +0 -0
  149. package/pb_public/assets/user-search-GUNMIBSB.js.gz +0 -0
  150. package/pb_public/assets/{viewer-2Y5FJBW4.js → viewer-BHKVAADP.js} +2 -2
  151. package/pb_public/assets/viewer-BHKVAADP.js.br +0 -0
  152. package/pb_public/assets/viewer-BHKVAADP.js.gz +0 -0
  153. package/pb_public/assets/viewer-JBZU46HP.css +2 -0
  154. package/pb_public/assets/viewer-JBZU46HP.css.br +0 -0
  155. package/pb_public/assets/viewer-JBZU46HP.css.gz +0 -0
  156. package/pb_public/assets/{viewer-P7GYCBYM.css.map → viewer-JBZU46HP.css.map} +2 -2
  157. package/pb_public/index.html +9 -8
  158. package/pb_public/stats.html +3 -3
  159. package/scripts/service.mjs +1 -1
  160. package/scripts/start.mjs +2 -1
  161. package/pb_public/assets/access-GPRLOZOO.css +0 -2
  162. package/pb_public/assets/access-GPRLOZOO.css.map +0 -7
  163. package/pb_public/assets/account-CT2BVMAX.css +0 -2
  164. package/pb_public/assets/account-CT2BVMAX.css.map +0 -7
  165. package/pb_public/assets/app-HB3NZHQ2.js +0 -3
  166. package/pb_public/assets/app-HB3NZHQ2.js.map +0 -7
  167. package/pb_public/assets/app-XJ73EU5O.css +0 -2
  168. package/pb_public/assets/app-XJ73EU5O.css.map +0 -7
  169. package/pb_public/assets/chunk-56ACD3V5.js +0 -2
  170. package/pb_public/assets/chunk-56ACD3V5.js.map +0 -7
  171. package/pb_public/assets/chunk-N2OFGBCZ.js +0 -2
  172. package/pb_public/assets/chunk-N2OFGBCZ.js.map +0 -7
  173. package/pb_public/assets/chunk-OKIIBH7O.js +0 -2
  174. package/pb_public/assets/chunk-OKIIBH7O.js.map +0 -7
  175. package/pb_public/assets/chunk-WR25F7FU.js +0 -2
  176. package/pb_public/assets/chunk-WR25F7FU.js.map +0 -7
  177. package/pb_public/assets/collections-DHJEOLHW.css +0 -2
  178. package/pb_public/assets/collections-DHJEOLHW.css.map +0 -7
  179. package/pb_public/assets/emoji-WWNPWCF3.css +0 -2
  180. package/pb_public/assets/emoji-WWNPWCF3.css.map +0 -7
  181. package/pb_public/assets/inbox-3FSOPY2T.css +0 -2
  182. package/pb_public/assets/inbox-3FSOPY2T.css.map +0 -7
  183. package/pb_public/assets/lazy-H3KIJVB5.js +0 -2
  184. package/pb_public/assets/lazy-H3KIJVB5.js.map +0 -7
  185. package/pb_public/assets/media-7TCBG7WM.css +0 -2
  186. package/pb_public/assets/media-7TCBG7WM.css.map +0 -7
  187. package/pb_public/assets/profile-3R6S5QYS.js +0 -2
  188. package/pb_public/assets/profile-3R6S5QYS.js.map +0 -7
  189. package/pb_public/assets/search-WCHOGAJQ.js +0 -2
  190. package/pb_public/assets/search-WCHOGAJQ.js.map +0 -7
  191. package/pb_public/assets/stats-A2TBRUI6.css +0 -2
  192. package/pb_public/assets/stats-A2TBRUI6.css.map +0 -7
  193. package/pb_public/assets/stats-GTO2H6PG.js.map +0 -7
  194. package/pb_public/assets/user-search-3HQOCQWL.js +0 -2
  195. package/pb_public/assets/viewer-P7GYCBYM.css +0 -2
  196. /package/pb_public/assets/{access-UK3L54NR.js.map → access-KVSI7EFH.js.map} +0 -0
  197. /package/pb_public/assets/{emoji-picker-K6JTK2GV.js.map → emoji-picker-W27IJER2.js.map} +0 -0
  198. /package/pb_public/assets/{forward-267HRNPY.js.map → forward-5TJEYGEV.js.map} +0 -0
  199. /package/pb_public/assets/{invite-OGT5E2MZ.js.map → invite-6BCBF4KV.js.map} +0 -0
  200. /package/pb_public/assets/{login-TK6K4WGB.js.map → login-FZY6GOMF.js.map} +0 -0
  201. /package/pb_public/assets/{media-WZ4653L5.js.map → media-VCJWBQJZ.js.map} +0 -0
  202. /package/pb_public/assets/{mention-suggest-ODJD2IC5.js.map → mention-suggest-K3UUHR4D.js.map} +0 -0
  203. /package/pb_public/assets/{user-search-3HQOCQWL.js.map → user-search-GUNMIBSB.js.map} +0 -0
  204. /package/pb_public/assets/{viewer-2Y5FJBW4.js.map → viewer-BHKVAADP.js.map} +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ Mentions & replies, which load on first use).
8
8
 
9
9
  <picture>
10
10
  <source media="(prefers-color-scheme: dark)" srcset="docs/screenshot-dark.png">
11
- <img alt="A room in Chirkle: the room list with unread counts on the left; messages with avatars, a reply, an @mention of you, a photo and emoji reactions on the right" src="docs/screenshot-light.png">
11
+ <img alt="A room in Chirkle: the sidebar on the left, with the faces of who mentioned you, unread dots and mention counts; messages with avatars, a reply, an @mention of you, a photo and emoji reactions on the right" src="docs/screenshot-light.png">
12
12
  </picture>
13
13
 
14
14
  - Runs on a $5 VPS (1 vCPU, 1 GB of RAM): about 1,000 people online at a normal pace (2,000
@@ -31,7 +31,7 @@ Mentions & replies, which load on first use).
31
31
  - Links in messages are clickable and open in a new tab (http, https and www. addresses only)
32
32
  - Emoji: a picker in the composer with search by name, ":name" suggestions as you type, and reactions on any message
33
33
  (as many different ones as you like), live for everyone
34
- - Attachments: up to 10 files of 20 MB per message, with an upload progress bar; images shown as thumbnails and videos as their first frame (4 tiles, then "+N"); files are private to whoever can read the message
34
+ - Attachments: up to 10 files of 20 MB per message, with an upload progress bar; images shown as thumbnails and videos as their first frame (4 tiles, then "+N"); files open by a link that can't be guessed, and stops working when the message is deleted
35
35
  - Image viewer: click a thumbnail to see it full size (or a video to play it) and step through the room's images and videos (buttons, arrow keys, swipe);
36
36
  loaded only when first used, so it adds nothing to the page's first load
37
37
  - Collections: save any image or video from the chat to collections of your own, public or private, and attach from them to messages; subscribe to other people's public collections to use theirs too, with a count of what's new and the new items highlighted; media attached from a collection link to it (or say "Private collection")
@@ -49,7 +49,7 @@ Mentions & replies, which load on first use).
49
49
  - Your own branding (title and logo) and, if you like, invite-only signups: set by the admin in PocketBase
50
50
  - Forgot password: once the admin sets up email, "Forgot password?" on the login page (web and Android) emails a link
51
51
  that sets a new password and logs out every device
52
- - Telegram bridge (optional): link rooms to Telegram groups through a bot; messages, replies, edits, files and (with the bot an admin) reactions go both ways (deletes from Chirkle to Telegram), Telegram people show under stand-in accounts with their names and pictures — see [Telegram integration](#telegram-integration)
52
+ - Telegram bridge (optional): link rooms to Telegram groups through a bot; messages, replies, edits, files and (with the bot an admin) reactions go both ways (deletes from Chirkle to Telegram), Telegram people show under stand-in accounts with their names and pictures — see [the Telegram bridge](https://chirkle.com/docs/telegram/)
53
53
  - Fast room switching: each room's latest messages are kept in the browser (IndexedDB) and shown at once while the
54
54
  server answers; unread rooms are fetched ahead. Attachment thumbnails are kept by the service worker, so going back
55
55
  to a room (or reloading) doesn't download them again. All of it is cleared on logout
@@ -59,13 +59,16 @@ Mentions & replies, which load on first use).
59
59
  - Installable as an app (PWA: Add to Home Screen, the browser's Install button); it opens offline to its shell
60
60
  - Optimistic sending with safe retries, reconnect gap-fill, light/dark themes, works on phones
61
61
  - A native Android app (Kotlin, Jetpack Compose) with the same features, notifications and a 3 MB download — see
62
- [Android app](#android-app)
62
+ [the Android app](https://chirkle.com/docs/android/)
63
63
 
64
64
  <picture>
65
65
  <source media="(prefers-color-scheme: dark)" srcset="docs/collections-dark.png">
66
66
  <img alt="A collection in Chirkle: the private Moodboard's pictures by month, with Upload, Rename and Make public; the sidebar lists your collections with their counts and a followed one with 3 new" src="docs/collections-light.png">
67
67
  </picture>
68
68
 
69
+ **Documentation: [chirkle.com/docs](https://chirkle.com/docs/)**: installing and deploying, the user guide, administration, the
70
+ Android app, linked servers, the Telegram bridge and the configuration reference.
71
+
69
72
  Design: [`docs/DESIGN.md`](docs/DESIGN.md) · Android app: [`docs/ANDROID.md`](docs/ANDROID.md) · QA: [`docs/QA.md`](docs/QA.md) · Refactoring plan: [`docs/REFACTOR.md`](docs/REFACTOR.md) · Archived plans: [MVP build](docs/history/BUILD_PLAN.md), [avatars, DMs, attachments](docs/history/NEXT_FEATURES_PLAN.md)
70
73
 
71
74
  ## Requirements
@@ -93,8 +96,7 @@ Open the page and sign up. The first run prints a link to create the admin (supe
93
96
  `npx chirkle superuser upsert you@example.com <password>` (`npm start -- superuser upsert …` in a clone).
94
97
  `HOST` and `PORT` choose the address (default `127.0.0.1:8090`; `HOST=0.0.0.0` to reach it from other machines),
95
98
  `CHIRKLE_DATA` the data directory (default `./pb_data`), and any other `pocketbase serve` flags can follow
96
- (`npx chirkle --http=0.0.0.0:80`). The settings of [Deploying](#deploying) (`TRUSTED_PROXY` behind a reverse proxy, …)
97
- apply as they are. The package ships the server built for Linux and macOS (x64, arm64): no Go or PocketBase download
99
+ (`npx chirkle --http=0.0.0.0:80`). Every setting is in the [configuration reference](https://chirkle.com/docs/reference/configuration/). The package ships the server built for Linux and macOS (x64, arm64): no Go or PocketBase download
98
100
  needed.
99
101
 
100
102
  ## Getting started (development)
@@ -130,8 +132,9 @@ The PocketBase admin UI is at http://127.0.0.1:8090/_/ (create a superuser with
130
132
  | `npm run doctor` | Is this machine ready for the tests? Go, the server binary, ffmpeg, versitygw, free space in `TMPDIR`, stray test servers, free e2e ports, and a browser that starts and draws text (`-- --browsers=chromium,firefox,webkit`). The e2e setup runs it first |
131
133
 
132
134
  Every test run starts its own PocketBase on a free port with a temp data dir — nothing to clean up, and no fakes
133
- except a stub Telegram Bot API for the bridge's tests. CI (`.github/workflows/ci.yml`) runs typecheck, lint and build, then unit, integration and e2e side by side, e2e once
134
- per browser (Chromium, Firefox, WebKit).
135
+ except a stub Telegram Bot API for the bridge's tests. CI (`.github/workflows/ci.yml`) runs small jobs all side by side, so a failed one is re-run alone: typecheck, lint,
136
+ build, Go, unit, component, integration (3 shards), e2e (2 shards per browser: Chromium, Firefox, WebKit), the speed
137
+ check, and the Android app's lint, tests and size. A final "CI passed" job is green only when all of them are.
135
138
 
136
139
  ## Project layout
137
140
 
@@ -151,150 +154,42 @@ android/ the Android app (docs/ANDROID.md): core/data (API, realtime, da
151
154
 
152
155
  ## Deploying
153
156
 
154
- ### systemd, in one command
155
-
156
- On a Linux server with Node 22+, with a domain pointing at it, this installs Chirkle as a systemd service that serves
157
- HTTPS itself (Let's Encrypt, on :80/:443):
157
+ On a Linux server with Node 22+ and a domain pointing at it, one command installs Chirkle as a systemd service that
158
+ serves HTTPS itself (Let's Encrypt, on :80/:443):
158
159
 
159
160
  ```sh
160
161
  sudo npx chirkle install-service chat.example.com
161
- sudo -u chirkle /opt/chirkle/chirkle-server superuser upsert you@example.com <password> --dir=/opt/chirkle/pb_data
162
- ```
163
-
164
- It copies the server, `pb_public/`, `pb_migrations/` and `pb_hooks/` to `/opt/chirkle`, creates the system user
165
- `chirkle`, which owns the data directory `/opt/chirkle/pb_data` (and nothing else), writes
166
- `/etc/systemd/system/chirkle.service` (sandboxed: `ProtectSystem`, `ProtectHome`, `NoNewPrivileges`), and enables and
167
- starts it. Run it again — `sudo npx chirkle@latest install-service chat.example.com` — to upgrade: the files are
168
- replaced and the service restarted, the data stays. `sudo npx chirkle uninstall-service` stops and removes the unit
169
- (files and data are left for you to delete).
170
-
171
- - Without a domain it listens on `127.0.0.1:8090` for a reverse proxy on the same machine, and sets
172
- `TRUSTED_PROXY=X-Forwarded-For` (see below); `--http=<addr>` picks another address (trusted only on loopback).
173
- - `--prefix=<dir>`, `--data=<dir>`, `--user=<name>`, `--name=<unit>` (several instances side by side) change the
174
- defaults; any other flag goes to `serve`.
175
- - `--dry-run` prints the unit file and what it would do, and changes nothing; use it to write the unit yourself.
176
- - More settings (`FFMPEG=`, other environment): `sudo systemctl edit chirkle`, which survives reinstalls.
177
-
178
- ### By hand
179
-
180
- Build once, then copy `bin/chirkle-server`, `pb_public/`, `pb_migrations/` and `pb_hooks/` to the server. It is PocketBase
181
- with the hot paths in Go (`server/`): the same commands and flags as the `pocketbase` binary. Go builds it for another
182
- platform with `GOOS`/`GOARCH` (`node scripts/build-server.mjs --all` builds them all into `bin/release/`).
183
- Migrations run automatically on start, and nothing is served until they are done, so they change only the database.
184
- What stored files need moving (the shared files of DESIGN.md §37) the media worker does afterwards, while the server
185
- runs.
186
-
187
- ```sh
188
- npm ci && npm run setup && npm run build
189
- rsync -a bin/chirkle-server pb_public pb_migrations pb_hooks server:/opt/chirkle/
190
- ```
191
-
192
- With a domain pointing at the server, PocketBase serves HTTPS itself (Let's Encrypt): run
193
- `chirkle-server serve chat.example.com --hooksPool=100 --dir=… --publicDir=… --migrationsDir=… --hooksDir=…` under your
194
- init system with `CAP_NET_BIND_SERVICE` (`npx chirkle install-service chat.example.com --dry-run` prints a systemd unit
195
- for it).
196
-
197
- Behind an existing reverse proxy instead, use `serve --http=127.0.0.1:8090` and proxy to it (keep
198
- `/api/realtime` unbuffered — it is a Server-Sent Events stream — and let request bodies through up to 210 MB, since a
199
- message may carry 10 files of 20 MB), and start PocketBase with
200
- `TRUSTED_PROXY=X-Forwarded-For` (`Environment=` in the unit). The rate limits are per client IP: without it, every
201
- request seems to come from the proxy, and one client tripping a limit trips it for everyone. The rightmost address of
202
- the header is used, the one your proxy added. The Docker image sets it (Dokku always runs a proxy in front); run it
203
- with `-e TRUSTED_PROXY=off` if clients reach port 8090 directly, since they could then choose their own IP. Unset, the
204
- setting is left as configured under *Settings → Application* in the admin UI.
205
-
206
- ### Dokku
207
-
208
- The `Dockerfile` builds the production image (frontend + pinned PocketBase), and `app.json` gives Dokku its health
209
- check. On the server:
210
-
211
- ```sh
212
- dokku apps:create chirkle
213
- # All data (SQLite + uploads) lives in /pb_data: keep it on the host. The directory is owned by uid 32767, the
214
- # image's user.
215
- dokku storage:ensure-directory chirkle
216
- dokku storage:mount chirkle /var/lib/dokku/data/storage/chirkle:/pb_data
217
- dokku domains:set chirkle chat.example.com
218
- # nginx allows 1 MB bodies by default; a message may carry 10 files of 20 MB.
219
- dokku nginx:set chirkle client-max-body-size 210m
220
- dokku letsencrypt:enable chirkle # with the dokku-letsencrypt plugin
221
162
  ```
222
163
 
223
- Then deploy. The light way is to run the image GitHub builds: after CI passes on `master`,
224
- `.github/workflows/image.yml` pushes `ghcr.io/border-radius/chirkle:<commit>` (and `:latest`), so the server only pulls
225
- and restarts, however many apps run it:
164
+ The documentation covers the rest:
226
165
 
227
- ```sh
228
- dokku git:from-image chirkle ghcr.io/border-radius/chirkle:<commit> # each deploy needs a new tag: use the commit
229
- ```
230
-
231
- To follow `master`, run that from cron with the commit `git ls-remote https://github.com/border-radius/chirkle.git
232
- refs/heads/master` names; until its image exists (CI and the build take a few minutes, and a commit that fails CI
233
- gets none) `docker pull` of it fails, and the app keeps running what it has.
234
-
235
- Or build on the server: `git push dokku master` from a clone with `dokku@server:chirkle` as the `dokku` remote, or
236
- `dokku git:sync --build chirkle https://github.com/border-radius/chirkle.git master`. Then create a superuser:
237
-
238
- ```sh
239
- dokku run chirkle /app/chirkle-server superuser upsert you@example.com <password> --dir=/pb_data
240
- ```
241
-
242
- Settings go in as environment variables (`dokku config:set chirkle KEY=value`, which restarts the app); the image already
243
- sets `TRUSTED_PROXY` for Dokku's proxy. `dokku logs chirkle -t` shows PocketBase's output; the app's own log (request
244
- log and errors from hooks) is in the admin UI under *Logs*.
245
-
246
- ### Running it
247
-
248
- **Branding and invite-only signups:** in the admin UI, *Collections → site*, edit the one record: `title` and `logo`
249
- are shown in the app bar, on the login page and in the tab's title. Tick `invite_only` and fill `invite_code` to let
250
- only people who have the code sign up (they enter it on the Sign up form; it is case-sensitive). Change the code to stop
251
- the old one working; leave it empty to close signups. Existing accounts are unaffected, and you can still create
252
- accounts yourself under *Collections → users*.
253
-
254
- **Moderators and statistics:** in the admin UI, *Collections → users*, tick `moderator` on someone's record. They
255
- then delete messages, change room access, archive rooms and ban people from the app (`banned` on the same record
256
- undoes a ban), and find usage statistics on Settings; superusers signed in to the admin UI open `/stats` directly.
257
- Tick `no_stats` on the *site* record to stop recording them.
258
-
259
- **Forgot password:** in the admin UI, set *Settings → Application → Application URL* to the server's public
260
- address (the emailed link starts with it) and the sender under *Settings → Mail settings*, and turn on *Use SMTP
261
- mail server* with your provider's host, port and login; *Send test email* checks it. Only then do the login pages
262
- offer "Forgot password?" (an SMTP server set but turned off isn't used). The link opens `/reset-password/…` on the
263
- web, works once for 30 minutes, and logs out every device of the account. The email's wording is under *Collections →
264
- users → Options → Default Password reset email template*; keep `{APP_URL}/reset-password/{TOKEN}` as its link.
265
-
266
- **Backups:** in the admin UI, *Settings → Backups* — schedule automatic backups (optionally to S3-compatible
267
- storage). Uploaded files (avatars, attachments) live in `pb_data/storage` (or S3, under *Settings → Files storage*) and
268
- are part of the backups, so plan disk space for them. **Rate limits** (per IP: messages 10 per 5 s, edits/deletes 20
269
- per 10 s, reactions 30 per 10 s, forwarding and deleting several messages 20 requests per minute each, password changes 5 per minute, password reset emails 5 per 10 minutes, new rooms 5 per minute, opening DMs 10 per minute, marking rooms read 120 per minute, signups 20 per minute; PocketBase defaults for the rest)
270
- are set by the migrations and adjustable under *Settings → Rate limits*.
166
+ - [Run it on a server](https://chirkle.com/docs/deploy/): the one-command install and its options, updating, uninstalling, and running the
167
+ server by hand
168
+ - [Docker](https://chirkle.com/docs/deploy/docker/) and [Dokku](https://chirkle.com/docs/deploy/dokku/), including running the image GitHub builds for every
169
+ commit on `master` and following it from cron
170
+ - [Behind a reverse proxy](https://chirkle.com/docs/deploy/reverse-proxy/): nginx and Caddy examples, and `TRUSTED_PROXY`
171
+ - [Administration](https://chirkle.com/docs/admin/): branding, invite-only signups, moderators, anonymous rooms, email, backups and S3,
172
+ rate limits, [link previews and video thumbnails](https://chirkle.com/docs/admin/previews-and-thumbnails/), metrics
173
+ - [Configuration reference](https://chirkle.com/docs/reference/configuration/): every environment variable, flag and setting in one place
271
174
 
272
175
  ## Android app
273
176
 
274
- In active development alongside the web client (it was frozen 2026-10-21..23): web features and fixes are ported to
275
- it ([`CLAUDE.md`](CLAUDE.md), [`android/PARITY.md`](android/PARITY.md)).
177
+ A native client for any server running Chirkle (Kotlin, Jetpack Compose), with several accounts at once on one server
178
+ or many, and notifications without Google services. Installing it, and what a server's admin can set up for it (room
179
+ links that open in the app, a minimum app version, a build for your own server):
180
+ [the Android app](https://chirkle.com/docs/android/) and [for admins](https://chirkle.com/docs/android/for-admins/).
276
181
 
277
- A native client for any server running Chirkle, with several accounts at once on one server or many (`android/`,
278
- design: [`docs/ANDROID.md`](docs/ANDROID.md), §17 for servers and accounts). It needs JDK 17+
279
- (21 recommended) and the Android SDK (`ANDROID_HOME`, or `sdk.dir` in `android/local.properties`); Gradle fetches the
280
- rest. Its tests start the server from `bin/`, so run `npm run setup` first.
182
+ To work on it (`android/`), you need JDK 17+ (21 recommended) and the Android SDK (`ANDROID_HOME`, or `sdk.dir` in
183
+ `android/local.properties`); Gradle fetches the rest. Its tests start the server from `bin/`, so run `npm run setup`
184
+ first.
281
185
 
282
186
  ```sh
283
187
  cd android
284
188
  ./gradlew assembleDebug # app/build/outputs/apk/debug: offers http://10.0.2.2:8090 (the dev server, from the emulator)
285
189
  ./gradlew check # lint, unit tests, API tests against PocketBase, UI tests on Robolectric
286
- ./gradlew checkApkSize -Pchirkle.server=https://chat.example.org -Pchirkle.appId=org.example.chirkle
287
190
  ```
288
191
 
289
- People choose their server when they log in or sign up (Change server), and add more accounts from their profile.
290
- A build only sets the server offered first: `-Pchirkle.devServer=http://192.168.1.20:8090` for a debug build on a device,
291
- `chirkle.server` for a release (without one, the app asks for a server, and no host's links open in the app). Debug builds
292
- take http addresses; release builds take https only. The app notifies of DMs and replies to you by checking each
293
- account's server about every 15 minutes (WorkManager), with no Google services and nothing to set up on the server
294
- (ANDROID.md §21). Links to rooms on the build's server open in the app once `ANDROID_CERT_SHA256` is
295
- set (`/.well-known/assetlinks.json`; `ANDROID_APP_ID` only for a build with another `chirkle.appId`). An admin can set
296
- `min_android_version` on the site record to make older apps ask for an update. What is built and what isn't yet:
297
- [`docs/ANDROID.md` §16](docs/ANDROID.md#16-implementation-2026-10-18), and [`android/PARITY.md`](android/PARITY.md).
192
+ Design: [`docs/ANDROID.md`](docs/ANDROID.md). What it has of the web app's features: [`android/PARITY.md`](android/PARITY.md).
298
193
 
299
194
  ## Releasing
300
195
 
@@ -305,77 +200,16 @@ Commit, push, then publish a GitHub Release with the new tag `v0.2.0`. The Relea
305
200
  stages `chirkle@0.2.0` on npm; approve it on npmjs.com (2FA) to publish it. Setup and details:
306
201
  [`docs/ANDROID.md` §28.7](docs/ANDROID.md#287-one-release-for-the-app-and-the-npm-package-2026-11-08).
307
202
 
308
- ## Link previews
309
-
310
- Messages show a line under them for each link: the page's favicon and title ([`docs/DESIGN.md` §28](docs/design/28-link-previews.md)).
311
- The server fetches them with `curl` (in the Docker image), only from public addresses. Set `LINK_PREVIEWS=off` to turn
312
- it off.
313
-
314
- ## Media grid
315
-
316
- Each room's Media button shows its images and videos as a grid ([`docs/DESIGN.md` §30](docs/design/30-media-grid.md)). A worker on
317
- the server makes their thumbnails ahead of time, and a poster frame for each video with `ffmpeg` (in the Docker
318
- image), which the room shows too, so browsers don't load videos just to draw their first frame. Set `FFMPEG=off` to
319
- go without: videos then show their first frame in the room as before, and plain tiles in the grid.
320
-
321
203
  ## Telegram integration
322
204
 
323
- An optional bridge between rooms and Telegram groups ([`docs/DESIGN.md` §26](docs/design/26-telegram-bridge.md)). A bot sits in your
324
- groups; once a group is linked to a room, messages, replies, edits and files go both ways (deletes only from Chirkle
325
- to Telegram), and reactions too where the bot is a group admin. Telegram people show in the room under stand-in users ("Ann Lee (TG)") with their names and pictures;
326
- the bot posts Chirkle messages with the author's name above them.
327
-
328
- **Setup**
329
-
330
- 1. Create a bot with [@BotFather](https://t.me/BotFather) (`/newbot`) and keep its token. Turn its privacy mode off
331
- (`/setprivacy` → Disable) so it sees group messages; if the bot is already in a group, remove it and add it again.
332
- 2. Set the environment and restart:
333
- - `TELEGRAM_BOT_TOKEN` — the bot's token (without it the bridge is off)
334
- - `TELEGRAM_WEBHOOK_URL` — `https://<your domain>/api/telegram/webhook` (without it the bridge polls Telegram,
335
- for local development)
336
-
337
- With Dokku: `dokku config:set chirkle TELEGRAM_BOT_TOKEN='…' TELEGRAM_WEBHOOK_URL='https://chat.example.com/api/telegram/webhook'`.
338
- 3. Add the bot to a Telegram group. A row for it appears in the admin UI under *Collections → tg_links*: pick the
339
- room and tick `enabled`. `/chatid` in the group says whether it is linked. Make the bot a group admin to bring
340
- reactions over: Telegram tells only admins about them. Tick `anonymous` too to repost the
341
- room's messages to that group without their authors' names.
342
-
343
- To make a room **anonymous**, tick `anonymous` on its row under *Collections → rooms* in the admin UI. Messages
344
- posted from then on show the room's name instead of their authors to everyone but the authors themselves (and
345
- superusers); see DESIGN.md §35. Telegram groups linked to it get the room's name as the author too.
346
-
347
- The bridge is self-contained: `pb_hooks/telegram.pb.js`, `pb_hooks/telegram/` and its own `tg_*` collections. Delete
348
- the first two to remove it.
205
+ Link rooms to Telegram groups and channels through your own bot: messages, replies, edits and files go both ways, and
206
+ reactions too with the bot an admin. Set `TELEGRAM_BOT_TOKEN` and `TELEGRAM_WEBHOOK_URL`, add the bot to a group, and
207
+ link the group to a room in the admin UI. Setup, options and limits: [the Telegram bridge](https://chirkle.com/docs/telegram/).
349
208
 
350
209
  ## Linked instances
351
210
 
352
- Two or more servers running this app can share rooms and let their people write DMs to each other
353
- ([`docs/DESIGN.md` §33](docs/design/33-linked-instances.md)). Each room has a home server; the others keep a copy, and messages, edits,
354
- replies, reactions and files go both ways. People from the other server show under stand-in users named after them
355
- ("Ann (B)"). Only the admins of both servers pair them and choose which rooms to share.
356
-
357
- **Setup** (on each server)
358
-
359
- 1. Turn it on: in the admin UI, set *Settings → Application → Application URL* to the server's public address, e.g.
360
- `https://chat.example.com`, then tick `federation` on the record under *Collections → site*. Peers are reached over
361
- https, on public addresses only. The address is part of the ids the peers keep, so it can't be changed while any
362
- peer is listed. (A server set up with the old `FEDERATION_ORIGIN` variable gets both done by its next start's
363
- migration; the variable is no longer read after that.)
364
- 2. Pair: on server A, under *Collections → fed_peers*, add a row with B's address and a short label for its people
365
- (`B`); tick `dms` to let people write DMs across. A sends B the request, and it shows on B as a row with status
366
- `requested` (B checks with A that it really asked). B's admin accepts by setting its status to `active`, choosing
367
- a label for A's people (and `dms`); both rows are then `active`. Deleting the request declines it. A request B
368
- can't be reached for is sent again every minute; one nobody accepts expires after 7 days. If both admins add
369
- each other, they pair at once.
370
- 3. Share a room: on its home, add a row under *fed_shares* with the room and the peer. The peer's admin finds it under
371
- *fed_shares* there and ticks `accepted`; the room then appears there, named "general (A)", with its latest 200
372
- messages. Private rooms too: each side's admins add their own people (on the copy, by editing its members), and the
373
- room's creator can add people from the other server by their address, `ann@b.example`.
374
- 4. DMs: with `dms` ticked on both sides, people type `name@b.example` in "New message".
375
-
376
- Suspend a peer by setting its `status` to `suspended`; delete its row to unpair (the copies are archived, DMs become
377
- read-only). The feature is self-contained: `pb_hooks/federation.pb.js`, `pb_hooks/federation/` and the `fed_*`
378
- collections; while `federation` isn't ticked, its routes answer 404 and nothing is sent.
211
+ Chirkle servers can be paired by their admins to share rooms, public or private, and let their people DM each other.
212
+ Off by default. Setup, sharing, moderation and unpairing: [linked servers](https://chirkle.com/docs/linking/).
379
213
 
380
214
  ## License
381
215
 
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/release/darwin-amd64/chirkle-server
3
- size: 33843680 bytes
4
- sha256: d3cb6ef1f9413c1584e9875fc55dadbb38534dc3b3f24b6e36d05b39d78d5cf1
3
+ size: 34443616 bytes
4
+ sha256: 699ea474005e640f9ea524a65f4ffe9fa9fd20fc1829614da19e91c1a77d08c0
package/package.json CHANGED
@@ -1,18 +1,30 @@
1
1
  {
2
2
  "name": "chirkle",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "A small, fast, real-time group chat: one PocketBase server, a vanilla TypeScript web app",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/border-radius/chirkle.git"
9
9
  },
10
- "homepage": "https://github.com/border-radius/chirkle#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/border-radius/chirkle/issues"
12
+ },
13
+ "homepage": "https://chirkle.com/",
11
14
  "keywords": [
12
15
  "chat",
13
- "pocketbase",
16
+ "messenger",
17
+ "team-chat",
18
+ "group-chat",
14
19
  "self-hosted",
15
- "realtime"
20
+ "selfhosted",
21
+ "slack-alternative",
22
+ "discord-alternative",
23
+ "telegram",
24
+ "pocketbase",
25
+ "sqlite",
26
+ "realtime",
27
+ "pwa"
16
28
  ],
17
29
  "type": "module",
18
30
  "bin": {
@@ -71,7 +83,7 @@
71
83
  "eventsource": "5.1.2",
72
84
  "happy-dom": "20.14.5",
73
85
  "playwright-core": "1.63.0",
74
- "pocketbase": "0.28.1",
86
+ "pocketbase": "0.29.0",
75
87
  "typescript": "7.0.2",
76
88
  "vitest": "5.0.2"
77
89
  },
@@ -162,11 +162,13 @@ function list(e) {
162
162
  .newQuery("SELECT id, name, public, items, last_added FROM collections WHERE owner = {:me} ORDER BY name_key, id")
163
163
  .bind({ me: user.id })
164
164
  .all(mine);
165
- const subs = arrayOf(new DynamicModel({ id: "", name: "", items: 0, last_added: "", owner: "", owner_name: "", seen_at: "", n: 0 }));
165
+ const subs = arrayOf(
166
+ new DynamicModel({ id: "", name: "", items: 0, last_added: "", owner: "", owner_name: "", owner_avatar: "", seen_at: "", n: 0 }),
167
+ );
166
168
  e.app
167
169
  .db()
168
170
  .newQuery(
169
- `SELECT c.id, c.name, c.items, c.last_added, c.owner, COALESCE(u.name, '') AS owner_name, s.seen_at, (
171
+ `SELECT c.id, c.name, c.items, c.last_added, c.owner, COALESCE(u.name, '') AS owner_name, COALESCE(u.avatar, '') AS owner_avatar, s.seen_at, (
170
172
  SELECT COUNT(*) FROM (
171
173
  SELECT 1 FROM collection_items i WHERE i.collection = c.id AND i.created > s.seen_at LIMIT ${NEW_CAP}
172
174
  )
@@ -195,7 +197,7 @@ function list(e) {
195
197
  public: true,
196
198
  items: c.items,
197
199
  last_added: c.last_added,
198
- owner: { id: c.owner, name: c.owner_name },
200
+ owner: { id: c.owner, name: c.owner_name, avatar: c.owner_avatar },
199
201
  seen_at: c.seen_at,
200
202
  new: c.n,
201
203
  preview: previews[c.id] ?? [],
@@ -10,8 +10,30 @@ const { nameKey } = require(`${__hooks}/lib/text.js`);
10
10
  const HANDLE_MIN = 3;
11
11
  const HANDLE_MAX = 24;
12
12
  const HANDLE = /^[a-z0-9_]{3,24}$/;
13
- /** Kept for what may one day mean everyone in a room. */
14
- const RESERVED = new Set(["all", "everyone", "here", "room", "channel"]);
13
+ /** Kept for what may one day mean everyone in a room: nobody has these (migration 46 took them back). */
14
+ const GROUP = ["all", "everyone", "here", "room", "channel"];
15
+ /**
16
+ * Words that would lend a stranger the site's authority in a mention ("@admin says…", QA SEC-2): not given to a new
17
+ * handle, nor taken in a change. Whoever has one already keeps it (and is still mentioned by it).
18
+ */
19
+ const STAFF = [
20
+ "admin",
21
+ "admins",
22
+ "administrator",
23
+ "chirkle",
24
+ "help",
25
+ "mod",
26
+ "moderator",
27
+ "moderators",
28
+ "mods",
29
+ "official",
30
+ "root",
31
+ "security",
32
+ "staff",
33
+ "support",
34
+ "system",
35
+ ];
36
+ const RESERVED = new Set([...GROUP, ...STAFF]);
15
37
  /** Most people one message mentions. */
16
38
  const MAX_MENTIONS = 20;
17
39
  /** Most people GET /api/chat/mentionable suggests. */
@@ -3,8 +3,8 @@
3
3
 
4
4
  const CSP = [
5
5
  "default-src 'self'",
6
- // The hash is index.html's inline theme script (web/src/theme.ts); tests/unit/build/csp.test.ts checks it.
7
- "script-src 'self' 'sha256-lMI93IRRLFIlto6GZfZdfPFeIgbs3CJfe2ncDiU/aWw='",
6
+ // The hash is index.html's inline theme and text size script (web/src/theme.ts); tests/unit/build/csp.test.ts checks it.
7
+ "script-src 'self' 'sha256-mOQF+ckehOwPXg3QQaTKo5nz/mkpPjspccYc517TGsE='",
8
8
  "style-src 'self'",
9
9
  "connect-src 'self'",
10
10
  "img-src 'self' data: blob:",
@@ -213,11 +213,12 @@ WHERE i.user = {:me} AND m.deleted = FALSE AND ${SEES_SQL}`;
213
213
 
214
214
  /**
215
215
  * A mention or reply whose message you have read in its room: seen there, so not new in the inbox either (2026-11-10,
216
- * user: no reading it twice). A reaction is only seen in the inbox: it comes after the message it is on. server/unread.go
217
- * counts by the same.
216
+ * user: no reading it twice). A reaction comes after the message it is on: it is seen there if it came before you last
217
+ * read the room (room_reads.reactions_seen_at, 2026-11-22, user: "when reading room, new reactions should be marked as
218
+ * seen"). server/unread.go counts by the same.
218
219
  */
219
- const READ_IN_ROOM_SQL = `(i.kind != 'reaction' AND m.created <= COALESCE((SELECT rr.last_read_at FROM room_reads rr
220
- WHERE rr.user = {:me} AND rr.room = i.room), ''))`;
220
+ const READ_IN_ROOM_SQL = `EXISTS (SELECT 1 FROM room_reads rr WHERE rr.user = {:me} AND rr.room = i.room
221
+ AND m.created <= rr.last_read_at AND (i.kind != 'reaction' OR i.created <= rr.reactions_seen_at))`;
221
222
 
222
223
  /** @param {string} s */
223
224
  const snippet = (s) => {
@@ -247,7 +248,7 @@ function shown(app, msg) {
247
248
  * GET /api/chat/inbox?before=&limit= → { items, more, seen_at }: the caller's rows, newest first, PAGE at a time
248
249
  * (`before`: the last item's `cursor`). Each item: { id, cursor, kind, emoji (a reaction row's: the actor's emoji on
249
250
  * the message now, at most EMOJI_SHOWN then " +n"; "" otherwise), emojis (all of them, in the message's order), created, read (a mention or reply read in
250
- * its room: not new, whatever seen_at says), room, message: { id, text, files,
251
+ * its room, or a reaction seen there: not new, whatever seen_at says), room, message: { id, text, files,
251
252
  * created }, quote (a reply's: the caller's message it answers, { id, text, files }), actor: { id, name, avatar,
252
253
  * instance } }. In an anonymous room (§35) a mention or reply shows the room, not who wrote it.
253
254
  * @param {core.RequestEvent} e
@@ -312,8 +312,8 @@ function thumbs(app, fs, row) {
312
312
  if (!THUMB_EXT.includes(ext(file))) return;
313
313
  const all = /** @type {any} */ (row.collection().fields.getByName("file")).thumbs ?? [];
314
314
  const recent = Date.now() - new Date(row.getString("created").replace(" ", "T")).getTime() < RECENT_MS;
315
- // A GIF shows itself in the room (§17.5): only the grid shows its thumbnail.
316
- const sizes = recent && ext(file) !== "gif" ? all : all.filter((/** @type {string} */ s) => s === GRID_THUMB);
315
+ // A GIF or a WebP shows itself in the room (§17.5): only the grid shows its thumbnail.
316
+ const sizes = recent && ext(file) !== "gif" && ext(file) !== "webp" ? all : all.filter((/** @type {string} */ s) => s === GRID_THUMB);
317
317
  for (const size of sizes) {
318
318
  const thumb = `${row.baseFilesPath()}/thumbs_${file}/${size}_${file}`;
319
319
  if (!fs.exists(thumb)) fs.createThumb(key, thumb, size);
@@ -109,9 +109,11 @@ function searchUsers(e) {
109
109
  function beforeUserSave(e) {
110
110
  const rec = recordOf(e);
111
111
  const email = rec.getString("email");
112
- if (rec.isNew() || email !== rec.original().getString("email")) rec.set("email", email.trim().toLowerCase());
112
+ const newEmail = rec.isNew() || email !== rec.original().getString("email");
113
+ if (newEmail) rec.set("email", email.trim().toLowerCase());
113
114
  // Signups and accounts a superuser makes are people; the bridges set their stand-ins' kind before saving.
114
115
  if (rec.isNew() && !rec.getString("kind")) rec.set("kind", "person");
116
+ if (newEmail && kindOf(rec) === "person") refuseMadeUpEmail(rec.getString("email"));
115
117
  if (kindOf(rec) === "deleted") {
116
118
  // A deleted account (§43, lib/account.js erase): one name for all of them, each with a key of its own (no name
117
119
  // is cleaned to a control character, so no one else's key is ever this), and no handle.
@@ -152,6 +154,25 @@ function findLoginByEmail(e) {
152
154
  }
153
155
  }
154
156
 
157
+ /**
158
+ * A person's address must be one mail can reach: not `….invalid` (RFC 2606), the made-up domain of stand-ins
159
+ * (`@telegram.invalid`, `@federation.invalid`, `@deleted.invalid`). Stand-ins are told apart by `kind` now, but a person
160
+ * with such an address looked like one to anything that went by the domain, and gets no mail (QA SEC-3).
161
+ * @param {string} email in lower case
162
+ */
163
+ function refuseMadeUpEmail(email) {
164
+ if (/\.invalid\.?$/.test(email)) throw fieldError("email", "Use an address that can receive e-mail.", "validation_invalid_email");
165
+ }
166
+
167
+ /**
168
+ * users request-email-change: the new address is refused at once, not only when its confirmation saves it.
169
+ * @param {core.RecordRequestEmailChangeRequestEvent} e
170
+ */
171
+ function checkEmailChange(e) {
172
+ if (!e.record || kindOf(e.record) === "person") refuseMadeUpEmail(e.newEmail.trim().toLowerCase());
173
+ return e.next();
174
+ }
175
+
155
176
  /**
156
177
  * users request-password-reset (§39): no email to a stand-in (Telegram, another instance): its address is made
157
178
  * up (`….invalid`) and nobody can log in as it (`kind`, §5.1). Answered like any other request, as PocketBase does for an unknown
@@ -164,4 +185,14 @@ function skipStandInReset(e) {
164
185
  return e.next();
165
186
  }
166
187
 
167
- module.exports = { DELETED_NAME, beforeUserSave, checkPasswordLength, findLoginByEmail, isStandIn, kindOf, searchUsers, skipStandInReset };
188
+ module.exports = {
189
+ DELETED_NAME,
190
+ beforeUserSave,
191
+ checkEmailChange,
192
+ checkPasswordLength,
193
+ findLoginByEmail,
194
+ isStandIn,
195
+ kindOf,
196
+ searchUsers,
197
+ skipStandInReset,
198
+ };
@@ -131,6 +131,7 @@ onRecordAuthWithPasswordRequest((e) => {
131
131
  }, "users");
132
132
 
133
133
  onRecordRequestPasswordResetRequest((e) => require(`${__hooks}/lib/users.js`).skipStandInReset(e), "users");
134
+ onRecordRequestEmailChangeRequest((e) => require(`${__hooks}/lib/users.js`).checkEmailChange(e), "users");
134
135
  onRecordConfirmPasswordResetRequest((e) => {
135
136
  require(`${__hooks}/lib/users.js`).checkPasswordLength(e.requestInfo().body.password);
136
137
  e.next();
@@ -336,6 +336,11 @@ function bringOver(app, link, room, msgs, mode = "live") {
336
336
  // one message comes as several: the first with the files and the reply, the rest after it.
337
337
  const save = (/** @type {boolean} */ withReply) =>
338
338
  app.runInTransaction((tx) => {
339
+ // Brought over meanwhile: Telegram sent it again while this one was downloading its files (a webhook retry
340
+ // after a slow answer). Checked again here, where writes go one at a time: the forgetStale below would
341
+ // otherwise take the first one's mappings for stale, and the worker, finding it from nowhere, would send the
342
+ // first one back to the group (QA BUG-291).
343
+ if (msgs.some((m) => partsMapped(tx, chatId, m.message_id, m.date).length)) return;
339
344
  const pieces = split(textOf(withReply));
340
345
  const ids = orderedIds(pieces.length);
341
346
  const rec = new Record(tx.findCollectionByNameOrId("messages"));
@@ -155,4 +155,15 @@ function tellLinkChange(app, link, was, now, why = "") {
155
155
  if (now) tellRoom(app, now, `${groupName(link)} was connected to this room.`);
156
156
  }
157
157
 
158
- module.exports = { linkOfChat, activeLink, linksOfRoom, ensureLink, moveLink, beforeLinkSave, linkedRoom, tellLinkChange };
158
+ module.exports = {
159
+ linkOfChat,
160
+ activeLink,
161
+ linksOfRoom,
162
+ ensureLink,
163
+ moveLink,
164
+ beforeLinkSave,
165
+ linkedRoom,
166
+ tellLinkChange,
167
+ groupName,
168
+ tellRoom,
169
+ };