diff --git a/app/api/inbox/route.ts b/app/api/inbox/route.ts index dfcb066..bae1ccc 100644 --- a/app/api/inbox/route.ts +++ b/app/api/inbox/route.ts @@ -1,3 +1,5 @@ +import crypto from 'node:crypto' + import { createPoll } from '@/lib/actions/createPoll' import { updateNote } from '@/lib/actions/updateNote' import { updatePoll } from '@/lib/actions/updatePoll' @@ -31,12 +33,16 @@ export const POST = ActivityPubVerifySenderGuard(async (request, context) => { const { storage } = context const body = await request.json() const activity = (await compact(body)) as StatusActivity + const deduplicationId = crypto + .createHash('sha256') + .update(JSON.stringify(activity.id)) + .digest('hex') switch (activity.type) { case CreateAction: { switch (activity.object.type) { case 'Note': { await getQueue().publish({ - id: activity.object.id, + id: deduplicationId, name: CREATE_NOTE_JOB_NAME, data: activity.object }) @@ -64,7 +70,7 @@ export const POST = ActivityPubVerifySenderGuard(async (request, context) => { } case AnnounceAction: { await getQueue().publish({ - id: activity.id, + id: deduplicationId, name: CREATE_ANNOUNCE_JOB_NAME, data: activity }) diff --git a/package.json b/package.json index ab57171..bf1743c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@date-fns/utc": "^1.2.0", "@google-cloud/firestore": "^7.9.0", "@jmondi/oauth2-server": "^4.0.2", - "@llun/activities.schema": "^0.2.7", + "@llun/activities.schema": "^0.2.8", "@opentelemetry/api": "^1.9.0", "@upstash/qstash": "2.7.2", "bcrypt": "^5.1.1", diff --git a/yarn.lock b/yarn.lock index 4fc6149..1d5a025 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2086,12 +2086,12 @@ __metadata: languageName: node linkType: hard -"@llun/activities.schema@npm:^0.2.7": - version: 0.2.7 - resolution: "@llun/activities.schema@npm:0.2.7" +"@llun/activities.schema@npm:^0.2.8": + version: 0.2.8 + resolution: "@llun/activities.schema@npm:0.2.8" dependencies: zod: "npm:^3.23.8" - checksum: 10c0/06abc84c5c4be4883b1124c39a606d096fd4e15dd7ad1eb2f7e2952febde6d6c263a49a5e1916a71ef5fd5753c4730651aa7ccf5dfc40b7e3b91c1c58c1c8d22 + checksum: 10c0/a1d1690c0f0a4da202d639959ac5c7bd74d3cd37129740ec1bce2b18e523cf70c72911dd5309631c6514ac271e20433b73bdc8afbd41a95c72608b3eb95d4509 languageName: node linkType: hard @@ -4157,7 +4157,7 @@ __metadata: "@date-fns/utc": "npm:^1.2.0" "@google-cloud/firestore": "npm:^7.9.0" "@jmondi/oauth2-server": "npm:^4.0.2" - "@llun/activities.schema": "npm:^0.2.7" + "@llun/activities.schema": "npm:^0.2.8" "@next/env": "npm:^14.2.7" "@opentelemetry/api": "npm:^1.9.0" "@swc-node/register": "npm:^1.10.9"