-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhydrate-community.ts
29 lines (26 loc) · 1005 Bytes
/
hydrate-community.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { readFileSync, writeFileSync } from "fs";
import { join } from "path";
import AtpAgent from "@atproto/api";
const agent = new AtpAgent({ service: 'https://bsky.social' })
const handle = 'martz.codes';
const password = process.env.BLUESKY_APP_PASSWORD || '';
const hydrateCommunity = async () => {
await agent.login({ identifier: handle, password })
const awsCommunity = JSON.parse(
readFileSync(join(__dirname, "bluesky-feed-parser/aws-community.json"), "utf-8")
);
const actors = Object.keys(awsCommunity);
for (const actor of actors) {
if (!awsCommunity[actor]) {
try {
const res = await agent.api.app.bsky.actor.getProfile({ actor });
awsCommunity[actor] = res?.data?.did || "";
} catch (e: any) {
console.log(`Error hydrating ${actor}: ${e.message}`);
}
}
}
// writeFileSync
writeFileSync(join(__dirname, "bluesky-feed-parser/aws-community.json"), JSON.stringify(awsCommunity, null, 2), "utf-8");
};
hydrateCommunity();