chirkle 0.0.0-stage → 0.2.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.
- package/LICENSE +674 -0
- package/README.md +326 -2
- package/package.json +76 -4
- package/pb_hooks/federation/config.js +276 -0
- package/pb_hooks/federation/inbox.js +316 -0
- package/pb_hooks/federation/messages.js +420 -0
- package/pb_hooks/federation/mirror.js +277 -0
- package/pb_hooks/federation/net.js +247 -0
- package/pb_hooks/federation/peers.js +490 -0
- package/pb_hooks/federation/people.js +376 -0
- package/pb_hooks/federation/rooms.js +552 -0
- package/pb_hooks/federation/worker.js +413 -0
- package/pb_hooks/federation.pb.js +141 -0
- package/pb_hooks/lib/access.js +102 -0
- package/pb_hooks/lib/account.js +31 -0
- package/pb_hooks/lib/anonymous.js +189 -0
- package/pb_hooks/lib/bulk.js +187 -0
- package/pb_hooks/lib/collections.js +587 -0
- package/pb_hooks/lib/dms.js +123 -0
- package/pb_hooks/lib/emoji.js +28 -0
- package/pb_hooks/lib/enrich.js +75 -0
- package/pb_hooks/lib/features.js +31 -0
- package/pb_hooks/lib/files.js +375 -0
- package/pb_hooks/lib/http.js +146 -0
- package/pb_hooks/lib/images.js +160 -0
- package/pb_hooks/lib/keepalive.js +31 -0
- package/pb_hooks/lib/lists.js +173 -0
- package/pb_hooks/lib/media.js +635 -0
- package/pb_hooks/lib/messages.js +519 -0
- package/pb_hooks/lib/moderation.js +128 -0
- package/pb_hooks/lib/outbound.js +116 -0
- package/pb_hooks/lib/pages.js +171 -0
- package/pb_hooks/lib/previews.js +346 -0
- package/pb_hooks/lib/reactions.js +110 -0
- package/pb_hooks/lib/reads.js +181 -0
- package/pb_hooks/lib/records.js +77 -0
- package/pb_hooks/lib/rooms.js +148 -0
- package/pb_hooks/lib/site.js +102 -0
- package/pb_hooks/lib/text.js +110 -0
- package/pb_hooks/lib/users.js +81 -0
- package/pb_hooks/lib/worker.js +159 -0
- package/pb_hooks/main.pb.js +324 -0
- package/pb_hooks/telegram/api.js +129 -0
- package/pb_hooks/telegram/inbound.js +553 -0
- package/pb_hooks/telegram/links.js +157 -0
- package/pb_hooks/telegram/outbound.js +352 -0
- package/pb_hooks/telegram/people.js +166 -0
- package/pb_hooks/telegram/reactions.js +137 -0
- package/pb_hooks/telegram/rich.js +192 -0
- package/pb_hooks/telegram/worker.js +182 -0
- package/pb_hooks/telegram.pb.js +47 -0
- package/pb_migrations/1760000000_init.js +150 -0
- package/pb_migrations/1760000001_qa_fixes.js +69 -0
- package/pb_migrations/1760000002_avatars.js +39 -0
- package/pb_migrations/1760000003_direct_messages.js +142 -0
- package/pb_migrations/1760000004_attachments.js +28 -0
- package/pb_migrations/1760000005_file_names.js +16 -0
- package/pb_migrations/1760000006_room_reads.js +41 -0
- package/pb_migrations/1760000007_replies.js +23 -0
- package/pb_migrations/1760000008_lowercase_emails.js +24 -0
- package/pb_migrations/1760000009_reactions.js +32 -0
- package/pb_migrations/1760000010_fit_thumbs.js +18 -0
- package/pb_migrations/1760000011_forwarding.js +39 -0
- package/pb_migrations/1760000012_accounts.js +55 -0
- package/pb_migrations/1760000013_qa_pass5.js +19 -0
- package/pb_migrations/1760000014_room_access.js +96 -0
- package/pb_migrations/1760000015_site.js +46 -0
- package/pb_migrations/1760000016_forward_refs.js +43 -0
- package/pb_migrations/1760000017_no_dms.js +18 -0
- package/pb_migrations/1760000018_attachment_limits.js +24 -0
- package/pb_migrations/1760000019_telegram.js +109 -0
- package/pb_migrations/1760000020_service_messages.js +21 -0
- package/pb_migrations/1760000021_forward_view_index.js +41 -0
- package/pb_migrations/1760000022_link_previews.js +43 -0
- package/pb_migrations/1760000023_room_writers.js +49 -0
- package/pb_migrations/1760000024_message_search.js +51 -0
- package/pb_migrations/1760000025_search_dotted_i.js +16 -0
- package/pb_migrations/1760000026_push.js +67 -0
- package/pb_migrations/1760000027_push_tokens_per_user.js +31 -0
- package/pb_migrations/1760000028_media_grid_thumbs.js +18 -0
- package/pb_migrations/1760000029_media.js +71 -0
- package/pb_migrations/1760000030_collections.js +140 -0
- package/pb_migrations/1760000031_unread_limit.js +20 -0
- package/pb_migrations/1760000032_federation.js +227 -0
- package/pb_migrations/1760000033_federation_requests.js +44 -0
- package/pb_migrations/1760000034_telegram_parts.js +26 -0
- package/pb_migrations/1760000035_telegram_anonymous.js +16 -0
- package/pb_migrations/1760000036_chirkle.js +20 -0
- package/pb_migrations/1760000037_file_dims.js +35 -0
- package/pb_migrations/1760000038_drop_push.js +64 -0
- package/pb_migrations/1760000039_anonymous_rooms.js +40 -0
- package/pb_migrations/1760000040_moderators.js +42 -0
- package/pb_migrations/1760000041_shared_files.js +500 -0
- package/pb_migrations/1760000042_files_src.js +17 -0
- package/pb_migrations/1760000043_telegram_reactions.js +21 -0
- package/pb_public/assets/access-ALBW2MT2.js +2 -0
- package/pb_public/assets/access-ALBW2MT2.js.map +7 -0
- package/pb_public/assets/access-PB77EH4F.css +2 -0
- package/pb_public/assets/access-PB77EH4F.css.map +7 -0
- package/pb_public/assets/app-A3SXD3FF.css +2 -0
- package/pb_public/assets/app-A3SXD3FF.css.map +7 -0
- package/pb_public/assets/app-NDSIQW4L.js +3 -0
- package/pb_public/assets/app-NDSIQW4L.js.map +7 -0
- package/pb_public/assets/collections-DHJEOLHW.css +2 -0
- package/pb_public/assets/collections-DHJEOLHW.css.map +7 -0
- package/pb_public/assets/emoji-WSTVXAW5.css +2 -0
- package/pb_public/assets/emoji-WSTVXAW5.css.map +7 -0
- package/pb_public/assets/emoji-picker-QYRX6NYL.js +609 -0
- package/pb_public/assets/emoji-picker-QYRX6NYL.js.map +7 -0
- package/pb_public/assets/inter-cyrillic-JEOLYBOO.woff2 +0 -0
- package/pb_public/assets/inter-cyrillic-ext-IYF56FF6.woff2 +0 -0
- package/pb_public/assets/inter-greek-IRE366VL.woff2 +0 -0
- package/pb_public/assets/inter-latin-NRMW37G5.woff2 +0 -0
- package/pb_public/assets/inter-latin-ext-HA22NDSG.woff2 +0 -0
- package/pb_public/assets/lazy-4CXRBHHM.js +2 -0
- package/pb_public/assets/lazy-4CXRBHHM.js.map +7 -0
- package/pb_public/assets/media-7TCBG7WM.css +2 -0
- package/pb_public/assets/media-7TCBG7WM.css.map +7 -0
- package/pb_public/assets/media-FPRU2QH5.js +2 -0
- package/pb_public/assets/media-FPRU2QH5.js.map +7 -0
- package/pb_public/assets/notify-L6GERFNO.js +2 -0
- package/pb_public/assets/notify-L6GERFNO.js.map +7 -0
- package/pb_public/assets/search-3UT4HMES.js +2 -0
- package/pb_public/assets/search-3UT4HMES.js.map +7 -0
- package/pb_public/assets/switcher-CEUKRLEY.js +2 -0
- package/pb_public/assets/switcher-CEUKRLEY.js.map +7 -0
- package/pb_public/assets/viewer-DXT7SKOU.js +2 -0
- package/pb_public/assets/viewer-DXT7SKOU.js.map +7 -0
- package/pb_public/assets/viewer-P7GYCBYM.css +2 -0
- package/pb_public/assets/viewer-P7GYCBYM.css.map +7 -0
- package/pb_public/icons/apple-touch-icon.png +0 -0
- package/pb_public/icons/icon-192.png +0 -0
- package/pb_public/icons/icon-512.png +0 -0
- package/pb_public/icons/icon.svg +1 -0
- package/pb_public/icons/maskable-512.png +0 -0
- package/pb_public/index.html +21 -0
- package/pb_public/sw.js +1 -0
- package/scripts/fetch-pocketbase.sh +63 -0
- package/scripts/start.mjs +93 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// Telegram bridge (DESIGN.md §26.6): tg_links.anonymous, a link whose group gets the room's messages without their
|
|
3
|
+
// authors' names, only what they say.
|
|
4
|
+
|
|
5
|
+
migrate(
|
|
6
|
+
(app) => {
|
|
7
|
+
const links = app.findCollectionByNameOrId("tg_links");
|
|
8
|
+
links.fields.add(new BoolField({ name: "anonymous" }));
|
|
9
|
+
app.save(links);
|
|
10
|
+
},
|
|
11
|
+
(app) => {
|
|
12
|
+
const links = app.findCollectionByNameOrId("tg_links");
|
|
13
|
+
links.fields.removeByName("anonymous");
|
|
14
|
+
app.save(links);
|
|
15
|
+
},
|
|
16
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// The app is called Chirkle; it was "Chat" until 2026-10-27. A site still titled "Chat", the title it was first
|
|
3
|
+
// given (1760000015_site.js), takes the new name. A title an admin chose stays as it is (DESIGN.md §24).
|
|
4
|
+
|
|
5
|
+
migrate(
|
|
6
|
+
(app) => {
|
|
7
|
+
for (const rec of app.findRecordsByFilter("site", "title = {:old}", "", 0, 0, { old: "Chat" })) {
|
|
8
|
+
if (!rec) continue;
|
|
9
|
+
rec.set("title", "Chirkle");
|
|
10
|
+
app.save(rec);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
(app) => {
|
|
14
|
+
for (const rec of app.findRecordsByFilter("site", "title = {:new}", "", 0, 0, { new: "Chirkle" })) {
|
|
15
|
+
if (!rec) continue;
|
|
16
|
+
rec.set("title", "Chat");
|
|
17
|
+
app.save(rec);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// Attachment shapes (DESIGN.md §17.5): `messages.file_dims` maps a stored image or video name → [width, height] as it
|
|
3
|
+
// is shown, so its tile has its size before it loads. The create hook sets an image's from its header; the media worker
|
|
4
|
+
// (pb_hooks/lib/media.js) a video's from its poster, and those of files sent before this from theirs: `media.sized`
|
|
5
|
+
// says it has looked at the row's file. A forward's rows are sized already: its original's rows do the work.
|
|
6
|
+
|
|
7
|
+
const C_NO_DIMS = "@request.body.file_dims:isset = false";
|
|
8
|
+
|
|
9
|
+
migrate(
|
|
10
|
+
(app) => {
|
|
11
|
+
const messages = app.findCollectionByNameOrId("messages");
|
|
12
|
+
messages.fields.add(new JSONField({ name: "file_dims", maxSize: 4096 }));
|
|
13
|
+
messages.createRule = `${messages.createRule} && ${C_NO_DIMS}`;
|
|
14
|
+
messages.updateRule = `${messages.updateRule} && ${C_NO_DIMS}`;
|
|
15
|
+
app.save(messages);
|
|
16
|
+
|
|
17
|
+
const media = app.findCollectionByNameOrId("media");
|
|
18
|
+
media.fields.add(new BoolField({ name: "sized" }));
|
|
19
|
+
media.addIndex("idx_media_unsized", false, "sent", "sized = FALSE");
|
|
20
|
+
app.save(media);
|
|
21
|
+
app.db().newQuery("UPDATE media SET sized = TRUE WHERE source != message").execute();
|
|
22
|
+
},
|
|
23
|
+
(app) => {
|
|
24
|
+
const messages = app.findCollectionByNameOrId("messages");
|
|
25
|
+
messages.fields.removeByName("file_dims");
|
|
26
|
+
messages.createRule = (messages.createRule ?? "").replace(` && ${C_NO_DIMS}`, "");
|
|
27
|
+
messages.updateRule = (messages.updateRule ?? "").replace(` && ${C_NO_DIMS}`, "");
|
|
28
|
+
app.save(messages);
|
|
29
|
+
|
|
30
|
+
const media = app.findCollectionByNameOrId("media");
|
|
31
|
+
media.removeIndex("idx_media_unsized");
|
|
32
|
+
media.fields.removeByName("sized");
|
|
33
|
+
app.save(media);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// Push notifications removed (docs/REFACTOR.md round 4): since docs/ANDROID.md §21 the app checks for notifications
|
|
3
|
+
// itself, so nothing registered push tokens any more and the push worker sent nothing. push_tokens and push_queue go;
|
|
4
|
+
// site.min_android_version (same migration as them, 1760000026) stays.
|
|
5
|
+
|
|
6
|
+
const PUSH_OWNER = "user = @request.auth.id";
|
|
7
|
+
|
|
8
|
+
migrate(
|
|
9
|
+
(app) => {
|
|
10
|
+
for (const name of ["push_queue", "push_tokens"]) {
|
|
11
|
+
try {
|
|
12
|
+
app.delete(app.findCollectionByNameOrId(name));
|
|
13
|
+
} catch {
|
|
14
|
+
// never made
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
(app) => {
|
|
19
|
+
const users = app.findCollectionByNameOrId("users");
|
|
20
|
+
const messages = app.findCollectionByNameOrId("messages");
|
|
21
|
+
app.save(
|
|
22
|
+
new Collection(
|
|
23
|
+
/** @type {any} */ ({
|
|
24
|
+
type: "base",
|
|
25
|
+
name: "push_tokens",
|
|
26
|
+
listRule: null,
|
|
27
|
+
viewRule: PUSH_OWNER,
|
|
28
|
+
createRule: `@request.auth.id != "" && @request.auth.collectionName = "users" && ${PUSH_OWNER}`,
|
|
29
|
+
updateRule: null,
|
|
30
|
+
deleteRule: PUSH_OWNER,
|
|
31
|
+
fields: [
|
|
32
|
+
{ type: "relation", name: "user", required: true, maxSelect: 1, collectionId: users.id, cascadeDelete: true },
|
|
33
|
+
{ type: "text", name: "token", required: true, min: 1, max: 1024 },
|
|
34
|
+
{ type: "select", name: "provider", required: true, maxSelect: 1, values: ["fcm", "unifiedpush"] },
|
|
35
|
+
{ type: "autodate", name: "created", onCreate: true, onUpdate: false },
|
|
36
|
+
{ type: "autodate", name: "updated", onCreate: true, onUpdate: true },
|
|
37
|
+
],
|
|
38
|
+
indexes: [
|
|
39
|
+
"CREATE UNIQUE INDEX idx_push_tokens_token_user ON push_tokens (token, user)",
|
|
40
|
+
"CREATE INDEX idx_push_tokens_user ON push_tokens (user)",
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
app.save(
|
|
46
|
+
new Collection(
|
|
47
|
+
/** @type {any} */ ({
|
|
48
|
+
type: "base",
|
|
49
|
+
name: "push_queue",
|
|
50
|
+
listRule: null,
|
|
51
|
+
viewRule: null,
|
|
52
|
+
createRule: null,
|
|
53
|
+
updateRule: null,
|
|
54
|
+
deleteRule: null,
|
|
55
|
+
fields: [
|
|
56
|
+
{ type: "relation", name: "message", required: true, maxSelect: 1, collectionId: messages.id, cascadeDelete: true },
|
|
57
|
+
{ type: "autodate", name: "created", onCreate: true, onUpdate: false },
|
|
58
|
+
],
|
|
59
|
+
indexes: ["CREATE INDEX idx_push_queue_created ON push_queue (created)"],
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// Anonymous rooms (DESIGN.md §35): `rooms.anonymous`, set by a superuser in the admin UI, and on each message whether
|
|
3
|
+
// its author is kept to themselves (`messages.anonymous`) and whether the author of the message it forwards is
|
|
4
|
+
// (`forwarded_anonymous`). The hooks set the messages' two when they are made; no client sets any of the three.
|
|
5
|
+
|
|
6
|
+
const C_NO_ANONYMOUS = "@request.body.anonymous:isset = false";
|
|
7
|
+
const C_NO_FORWARDED_ANONYMOUS = "@request.body.forwarded_anonymous:isset = false";
|
|
8
|
+
|
|
9
|
+
migrate(
|
|
10
|
+
(app) => {
|
|
11
|
+
const rooms = app.findCollectionByNameOrId("rooms");
|
|
12
|
+
rooms.fields.add(new BoolField({ name: "anonymous" }));
|
|
13
|
+
rooms.createRule = `${rooms.createRule} && ${C_NO_ANONYMOUS}`;
|
|
14
|
+
rooms.updateRule = `${rooms.updateRule} && ${C_NO_ANONYMOUS}`;
|
|
15
|
+
app.save(rooms);
|
|
16
|
+
|
|
17
|
+
const messages = app.findCollectionByNameOrId("messages");
|
|
18
|
+
messages.fields.add(new BoolField({ name: "anonymous" }));
|
|
19
|
+
messages.fields.add(new BoolField({ name: "forwarded_anonymous" }));
|
|
20
|
+
messages.createRule = `${messages.createRule} && ${C_NO_ANONYMOUS} && ${C_NO_FORWARDED_ANONYMOUS}`;
|
|
21
|
+
messages.updateRule = `${messages.updateRule} && ${C_NO_ANONYMOUS} && ${C_NO_FORWARDED_ANONYMOUS}`;
|
|
22
|
+
app.save(messages);
|
|
23
|
+
},
|
|
24
|
+
(app) => {
|
|
25
|
+
const rooms = app.findCollectionByNameOrId("rooms");
|
|
26
|
+
rooms.fields.removeByName("anonymous");
|
|
27
|
+
rooms.createRule = (rooms.createRule ?? "").replace(` && ${C_NO_ANONYMOUS}`, "");
|
|
28
|
+
rooms.updateRule = (rooms.updateRule ?? "").replace(` && ${C_NO_ANONYMOUS}`, "");
|
|
29
|
+
app.save(rooms);
|
|
30
|
+
|
|
31
|
+
const messages = app.findCollectionByNameOrId("messages");
|
|
32
|
+
messages.fields.removeByName("anonymous");
|
|
33
|
+
messages.fields.removeByName("forwarded_anonymous");
|
|
34
|
+
for (const c of [C_NO_ANONYMOUS, C_NO_FORWARDED_ANONYMOUS]) {
|
|
35
|
+
messages.createRule = (messages.createRule ?? "").replace(` && ${c}`, "");
|
|
36
|
+
messages.updateRule = (messages.updateRule ?? "").replace(` && ${c}`, "");
|
|
37
|
+
}
|
|
38
|
+
app.save(messages);
|
|
39
|
+
},
|
|
40
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference path="../types/pocketbase.d.ts" />
|
|
2
|
+
// Moderators (DESIGN.md §36): `users.moderator`, ticked by a superuser in the admin UI, and `users.banned`, set by a
|
|
3
|
+
// moderator (POST /api/chat/ban) or a superuser. No client sets either on a users record; a banned account can't sign
|
|
4
|
+
// in (authRule). A moderator changes any public room's access and archives it, as its creator does, but doesn't rename
|
|
5
|
+
// it.
|
|
6
|
+
|
|
7
|
+
const C_NO_MODERATOR = "@request.body.moderator:isset = false";
|
|
8
|
+
const C_NO_BANNED = "@request.body.banned:isset = false";
|
|
9
|
+
const ROOM_OWNER = "created_by = @request.auth.id";
|
|
10
|
+
const ROOM_OWNER_OR_MODERATOR = `(${ROOM_OWNER} || (@request.auth.moderator = true && @request.body.name:isset = false))`;
|
|
11
|
+
|
|
12
|
+
migrate(
|
|
13
|
+
(app) => {
|
|
14
|
+
const users = app.findCollectionByNameOrId("users");
|
|
15
|
+
users.fields.add(new BoolField({ name: "moderator" }));
|
|
16
|
+
users.fields.add(new BoolField({ name: "banned" }));
|
|
17
|
+
users.createRule = `${users.createRule} && ${C_NO_MODERATOR} && ${C_NO_BANNED}`;
|
|
18
|
+
users.updateRule = `${users.updateRule} && ${C_NO_MODERATOR} && ${C_NO_BANNED}`;
|
|
19
|
+
users.authRule = "banned = false";
|
|
20
|
+
app.save(users);
|
|
21
|
+
|
|
22
|
+
const rooms = app.findCollectionByNameOrId("rooms");
|
|
23
|
+
if (!(rooms.updateRule ?? "").startsWith(`${ROOM_OWNER} && `)) throw new Error("rooms.updateRule doesn't start with its owner check");
|
|
24
|
+
rooms.updateRule = ROOM_OWNER_OR_MODERATOR + (rooms.updateRule ?? "").slice(ROOM_OWNER.length);
|
|
25
|
+
app.save(rooms);
|
|
26
|
+
},
|
|
27
|
+
(app) => {
|
|
28
|
+
const users = app.findCollectionByNameOrId("users");
|
|
29
|
+
users.fields.removeByName("moderator");
|
|
30
|
+
users.fields.removeByName("banned");
|
|
31
|
+
for (const c of [C_NO_MODERATOR, C_NO_BANNED]) {
|
|
32
|
+
users.createRule = (users.createRule ?? "").replace(` && ${c}`, "");
|
|
33
|
+
users.updateRule = (users.updateRule ?? "").replace(` && ${c}`, "");
|
|
34
|
+
}
|
|
35
|
+
users.authRule = "";
|
|
36
|
+
app.save(users);
|
|
37
|
+
|
|
38
|
+
const rooms = app.findCollectionByNameOrId("rooms");
|
|
39
|
+
rooms.updateRule = (rooms.updateRule ?? "").replace(ROOM_OWNER_OR_MODERATOR, ROOM_OWNER);
|
|
40
|
+
app.save(rooms);
|
|
41
|
+
},
|
|
42
|
+
);
|