an attempt to make a lightweight, easily self-hostable, scoped bluesky appview
1import { Database } from "jsr:@db/sqlite@0.11";
2import { config } from "../config.ts";
3import { resolveRecordFromURI } from "../utils/records.ts";
4import { JetstreamManager } from "../utils/sharders.ts";
5
6export function startJetstream(jetstreamManager: JetstreamManager) {
7 jetstreamManager.start({
8 // for realsies pls get from db or something instead of this shit
9 wantedDids: [
10 "did:plc:mn45tewwnse5btfftvd3powc",
11 "did:plc:yy6kbriyxtimkjqonqatv2rb",
12 "did:plc:zzhzjga3ab5fcs2vnsv2ist3",
13 "did:plc:jz4ibztn56hygfld6j6zjszg",
14 ],
15 wantedCollections: [
16 "app.bsky.actor.profile",
17 "app.bsky.feed.generator",
18 "app.bsky.feed.like",
19 "app.bsky.feed.post",
20 "app.bsky.feed.repost",
21 "app.bsky.feed.threadgate",
22 "app.bsky.graph.block",
23 "app.bsky.graph.follow",
24 "app.bsky.graph.list",
25 "app.bsky.graph.listblock",
26 "app.bsky.graph.listitem",
27 "app.bsky.notification.declaration",
28 ],
29 });
30}
31
32export async function handleJetstream(msg: any, handleIndex: Function) {
33 console.log("Received Jetstream message: ", msg);
34
35 const op = msg.commit.operation;
36 const doer = msg.did;
37 const rev = msg.commit.rev;
38 const aturi = `${msg.did}/${msg.commit.collection}/${msg.commit.rkey}`;
39 const value = msg.commit.record;
40
41 if (!doer || !value) return;
42
43 handleIndex({
44 op,
45 doer,
46 rev,
47 aturi,
48 value,
49 indexsrc: "jetstream",
50 })
51 return;
52
53 // switch (msg.commit.collection) {
54 // case "app.bsky.feed.like":
55 // switch (op) {
56 // case "create":
57 // // idk
58 // return;
59 // case "update":
60 // // whatever
61 // return;
62 // case "delete":
63 // // lmao
64 // return;
65 // }
66 // }
67}