tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
29
pulls
pipelines
don't sync bsky likes of brid.gy posts
awarm.space
1 month ago
64c07c71
6e976975
+15
-1
1 changed file
expand all
collapse all
unified
split
app
api
inngest
functions
sync_bsky_likes.ts
+15
-1
app/api/inngest/functions/sync_bsky_likes.ts
···
1
1
import { inngest } from "../client";
2
2
import { supabaseServerClient } from "supabase/serverClient";
3
3
-
import { AtpAgent } from "@atproto/api";
3
3
+
import { AtpAgent, AtUri } from "@atproto/api";
4
4
+
import { idResolver } from "app/(home-pages)/reader/idResolver";
4
5
5
6
const TOTAL_ITERATIONS = 144; // 36 hours at 15-minute intervals
6
7
···
12
13
{ event: "appview/sync-bsky-likes" },
13
14
async ({ event, step }) => {
14
15
const { document_uri, bsky_post_uri } = event.data;
16
16
+
17
17
+
const isBridgy = await step.run("check-bridgy", async () => {
18
18
+
const did = new AtUri(bsky_post_uri).host;
19
19
+
const doc = await idResolver.did.resolve(did);
20
20
+
const handle = doc?.alsoKnownAs
21
21
+
?.find((a) => a.startsWith("at://"))
22
22
+
?.replace("at://", "");
23
23
+
return handle?.includes("brid.gy") ?? false;
24
24
+
});
25
25
+
26
26
+
if (isBridgy) {
27
27
+
return { skipped: true, reason: "brid.gy post" };
28
28
+
}
15
29
16
30
const agent = new AtpAgent({ service: "https://public.api.bsky.app" });
17
31