+56
-2
config.json
+56
-2
config.json
···
1
1
{
2
2
"jetstream_url": "wss://jetstream2.us-west.bsky.network/subscribe",
3
3
"es_url": "http://localhost:9200",
4
-
"record_types": ["xyz.statusphere.status", "com.example.test.esav"],
4
+
"record_types": [
5
+
"xyz.statusphere.status",
6
+
"com.example.test.esav",
7
+
"party.whey.ft.topic.post",
8
+
"party.whey.ft.topic.reaction",
9
+
"party.whey.ft.topic.moderation",
10
+
"party.whey.ft.forum.definition",
11
+
"party.whey.ft.forum.layout",
12
+
"party.whey.ft.forum.request",
13
+
"party.whey.ft.forum.accept",
14
+
"party.whey.ft.forum.category",
15
+
"party.whey.ft.user.profile"
16
+
],
5
17
"index_name": "appview-poc",
6
18
"serve_port": "8370",
7
19
"index_fields": {
20
+
"party.whey.ft.topic.reaction": {
21
+
"subject": {
22
+
"id": "reactionSubject",
23
+
"type": "keyword"
24
+
},
25
+
"reactionEmoji": {
26
+
"id": "reactionEmoji",
27
+
"type": "keyword"
28
+
}
29
+
},
30
+
"party.whey.ft.topic.post": {
31
+
"text": {
32
+
"id": "text",
33
+
"type": "text"
34
+
},
35
+
"title": {
36
+
"id": "title",
37
+
"type": "text"
38
+
},
39
+
"reply.root.uri": {
40
+
"id": "root",
41
+
"type": "keyword"
42
+
},
43
+
"reply.parent.uri": {
44
+
"id": "parent",
45
+
"type": "keyword"
46
+
},
47
+
"forum": {
48
+
"id": "forum",
49
+
"type": "keyword"
50
+
}
51
+
},
52
+
"party.whey.ft.forum.definition": {
53
+
"description": {
54
+
"id": "description",
55
+
"type": "text"
56
+
},
57
+
"displayName": {
58
+
"id": "displayName",
59
+
"type": "text"
60
+
}
61
+
},
8
62
"xyz.statusphere.status": {
9
63
"status": {
10
64
"id": "status",
11
-
"type": "text"
65
+
"type": "keyword"
12
66
}
13
67
},
14
68
"com.example.test.esav": {
+26
-5
readme.md
+26
-5
readme.md
···
94
94
with these params:
95
95
- `did`: The DID of the user.
96
96
- `handle`: The handle of the user.
97
-
- `includePfp` (optional): `true` to include the PFP URL.
97
+
- `includeBskyProfile` (optional): `true` to include the the entire bsky profile object as well.
98
98
99
99
**Example Request:**
100
100
101
-
`https://esav.whey.party/xrpc/party.whey.esav.resolveIdentity?did=did:web:did12.whey.party&includePfp=true`
101
+
`https://esav.whey.party/xrpc/party.whey.esav.resolveIdentity?did=did:plc:cjfima2v3vnyfuzieu7bvjx7&includeBskyProfile=true`
102
102
103
103
gets me
104
104
···
106
106
107
107
```json
108
108
{
109
-
"did":"did:web:did12.whey.party",
109
+
"did":"did:plc:cjfima2v3vnyfuzieu7bvjx7",
110
110
"pdsUrl":"https://pds-nd.whey.party",
111
-
"handle":"dw.whey.party",
112
-
"pfp":"https://pds-nd.whey.party/xrpc/com.atproto.sync.getBlob?did=did:web:did12.whey.party&cid=bafkreibesqir3254ee3natyi3tadhmcjqyyeukoiqxsctsru7z3j4ws4mm"
111
+
"handle":"forumtest.whey.party",
112
+
"profile": {
113
+
"$type": "app.bsky.actor.profile",
114
+
"avatar": {
115
+
"$type": "blob",
116
+
"ref": {
117
+
"$link": "bafkreiabb6nrbpgguh5xaake3shoyxh2i7lyj7nj7j3ejk77hdlvt4lhmu"
118
+
},
119
+
"mimeType": "image/png",
120
+
"size": 35262
121
+
},
122
+
"banner": {
123
+
"$type": "blob",
124
+
"ref": {
125
+
"$link": "bafkreieupktgazj4vxuxbj6dyf4trvltgok5ukdsnvvblsqqw26cmsvn7y"
126
+
},
127
+
"mimeType": "image/jpeg",
128
+
"size": 931415
129
+
},
130
+
"createdAt": "2025-08-04T06:27:34.561Z",
131
+
"description": "ForumTest discussion and development",
132
+
"displayName": "ForumTest"
133
+
}
113
134
}
114
135
```
115
136
+6
-1
src/firehose.ts
+6
-1
src/firehose.ts
···
4
4
interface FirehoseOptions {
5
5
config: AppConfig;
6
6
onEvent: OnEventCallback;
7
+
forcedCursor?: string;
7
8
}
8
9
9
-
export function startFirehose({ config, onEvent }: FirehoseOptions) {
10
+
export function startFirehose({ config, onEvent, forcedCursor }: FirehoseOptions) {
10
11
let lastCursor: number | null = null;
11
12
12
13
const connect = () => {
13
14
const url = new URL(config.jetstream_url);
14
15
if (lastCursor !== null) {
15
16
url.searchParams.set("cursor", lastCursor.toString());
17
+
}
18
+
if (forcedCursor) {
19
+
console.log("using forced cursor: ", forcedCursor)
20
+
url.searchParams.set("cursor", forcedCursor);
16
21
}
17
22
18
23
const ws = new WebSocket(url.toString());
+14
src/live-utils.ts
+14
src/live-utils.ts
···
50
50
break;
51
51
}
52
52
53
+
case 'terms': {
54
+
const [field, queryValues] = Object.entries(clauseValue as object)[0];
55
+
if (!Array.isArray(queryValues)) return false;
56
+
57
+
const docValue = getSafeField(doc, field);
58
+
if (docValue === undefined) return false;
59
+
60
+
if (Array.isArray(docValue)) {
61
+
return docValue.some(v => queryValues.includes(v));
62
+
} else {
63
+
return queryValues.includes(docValue);
64
+
}
65
+
}
66
+
53
67
case 'match': {
54
68
const [field, value] = Object.entries(clauseValue as object)[0];
55
69
const fieldValue = getSafeField(doc, field);
+5
-1
src/main.ts
+5
-1
src/main.ts
···
3
3
import { ensureIndexMapping, type IndexerEvent } from "./indexer.ts";
4
4
import { setupXRPCServer } from "./xrpc.ts";
5
5
import { processEventForSync } from "./sync.ts";
6
+
import { parseArgs } from "jsr:@std/cli";
6
7
7
8
async function main() {
8
9
const config = await readConfig("./config.json");
10
+
11
+
const args = parseArgs(Deno.args)
9
12
10
13
// prepare indexes
11
14
await ensureIndexMapping(config);
···
17
20
onEvent: (event: IndexerEvent) => {
18
21
// ESAV Live !!!
19
22
return processEventForSync(event);
20
-
}
23
+
},
24
+
forcedCursor: args["force-cursor"]
21
25
});
22
26
23
27
console.log("Server started and listening for events");
+8
-8
src/xrpc.ts
+8
-8
src/xrpc.ts
···
68
68
const handle = searchParams.get("handle");
69
69
const did = searchParams.get("did");
70
70
const clientCid = searchParams.get("cid");
71
-
const includePfp = searchParams.get("includePfp");
71
+
const includeBskyProfile = searchParams.get("includeBskyProfile");
72
72
73
73
if (!handle && !did) {
74
74
return new Response("handle or did parameter is required", {
···
86
86
...identity,
87
87
};
88
88
89
-
if (includePfp) {
90
-
finalResponse.pfp = await getPfpUrl(identity.pdsUrl, identity.did);
89
+
if (includeBskyProfile) {
90
+
finalResponse.profile = await getProfileRecord(identity.pdsUrl, identity.did);
91
91
}
92
92
93
93
const newCid = await computeCid(finalResponse);
···
513
513
}
514
514
}
515
515
516
-
async function getPfpUrl(
516
+
async function getProfileRecord(
517
517
pdsUrl: string,
518
518
did: string
519
519
): Promise<string | undefined> {
···
527
527
return undefined;
528
528
}
529
529
const data = await response.json();
530
-
const cid = data?.value?.avatar?.ref?.["$link"];
531
-
const pfpurl = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}`;
532
-
return pfpurl;
530
+
//const cid = data?.value?.avatar?.ref?.["$link"];
531
+
//const pfpurl = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}`;
532
+
return data.value;
533
533
} catch (error) {
534
-
console.error(`Error fetching PFP for ${did}:`, error);
534
+
console.error(`Error fetching profile record for ${did}:`, error);
535
535
return undefined;
536
536
}
537
537
}