a tool for shared writing and social publishing

fix syncing leaflet published post bsky likes

+13 -5
+13 -5
app/api/inngest/functions/sync_document_metadata.ts
··· 3 3 import { AtpAgent, AtUri } from "@atproto/api"; 4 4 import { idResolver } from "app/(home-pages)/reader/idResolver"; 5 5 6 - const TOTAL_ITERATIONS = 144; // 36 hours at 15-minute intervals 6 + // 1m, 2m, 4m, 8m, 16m, 32m, 1h, 2h, 4h, 8h, 8h, 8h (~37h total) 7 + const SLEEP_INTERVALS = [ 8 + "1m", "2m", "4m", "8m", "16m", "32m", "1h", "2h", "4h", "8h", "8h", "8h", 9 + ]; 7 10 8 11 export const sync_document_metadata = inngest.createFunction( 9 12 { 10 13 id: "sync_document_metadata", 11 - idempotency: "event.data.document_uri", 14 + debounce: { 15 + key: "event.data.document_uri", 16 + period: "60s", 17 + timeout: "3m", 18 + }, 19 + concurrency: [{ key: "event.data.document_uri", limit: 1 }], 12 20 }, 13 21 { event: "appview/sync-document-metadata" }, 14 22 async ({ event, step }) => { ··· 61 69 62 70 let likeCount = await step.run("sync-0", fetchAndUpdate); 63 71 64 - for (let i = 1; i < TOTAL_ITERATIONS; i++) { 65 - await step.sleep(`wait-${i}`, "15m"); 66 - likeCount = await step.run(`sync-${i}`, fetchAndUpdate); 72 + for (let i = 0; i < SLEEP_INTERVALS.length; i++) { 73 + await step.sleep(`wait-${i + 1}`, SLEEP_INTERVALS[i]); 74 + likeCount = await step.run(`sync-${i + 1}`, fetchAndUpdate); 67 75 } 68 76 69 77 return { likeCount, handle: handleResult.handle };