this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

maybe better error handling

+37 -8
+17 -7
src/label.ts
··· 1 - import { BskyAgent } from "@atproto/api"; 1 + import { AppBskyActorDefs, BskyAgent } from "@atproto/api"; 2 2 import { DID, PRONOUNS, URIs } from "./constants.js"; 3 3 4 - export const label = async (agent: BskyAgent, subject: string, uri: string) => { 4 + export const label = async ( 5 + agent: BskyAgent, 6 + subject: string | AppBskyActorDefs.ProfileView, 7 + uri: string, 8 + ) => { 9 + const did = AppBskyActorDefs.isProfileView(subject) ? subject.did : subject; 5 10 const repo = await agent 6 11 .withProxy("atproto_labeler", DID) 7 - .api.tools.ozone.moderation.getRepo({ did: subject }); 12 + .api.tools.ozone.moderation.getRepo({ did: did }) 13 + .catch((err) => console.log(err)); 14 + 15 + if (!repo) return; 8 16 9 17 const post = URIs[uri]; 10 18 ··· 19 27 }, 20 28 subject: { 21 29 $type: "com.atproto.admin.defs#repoRef", 22 - did: subject, 30 + did: did, 23 31 }, 24 32 createdBy: agent.session!.did, 25 33 createdAt: new Date().toISOString(), 26 34 subjectBlobCids: [], 27 - }); 35 + }) 36 + .catch((err) => console.log(err)); 28 37 return; 29 38 } 30 39 ··· 41 50 }, 42 51 subject: { 43 52 $type: "com.atproto.admin.defs#repoRef", 44 - did: subject, 53 + did: did, 45 54 }, 46 55 createdBy: agent.session!.did, 47 56 createdAt: new Date().toISOString(), 48 57 subjectBlobCids: [], 49 58 }) 50 - .then(() => console.log(`Labeled ${subject} with ${post}`)); 59 + .catch((err) => console.log(err)) 60 + .then(() => console.log(`Labeled ${did} with ${post}`)); 51 61 } 52 62 };
+20 -1
src/main.ts
··· 3 3 import { getAgent } from "./agent.js"; 4 4 import { label } from "./label.js"; 5 5 import { DID } from "./constants.js"; 6 + import "dotenv/config"; 6 7 7 8 const subscribe = async () => { 8 9 const agent = await getAgent(); 9 10 10 11 // add firehose cursor save 11 - const firehose = new Firehose({ cursor: "759165458" }); 12 + const firehose = new Firehose(); 13 + 14 + firehose.on("error", ({ cursor }) => { 15 + agent.api.chat.bsky.convo.sendMessage( 16 + { 17 + convoId: process.env.CONVO_ID ?? "", 18 + message: { 19 + text: `Firehose errored on cursor: ${cursor}`, 20 + }, 21 + }, 22 + { 23 + encoding: "application/json", 24 + headers: { 25 + "atproto-proxy": "did:web:api.bsky.chat#bsky_chat", 26 + }, 27 + }, 28 + ); 29 + }); 30 + 12 31 firehose.on("commit", (commit) => { 13 32 for (const op of commit.ops) { 14 33 if (op.action === "delete") continue;