Skip to content

Commit

Permalink
Fix Tag schema and qstash dedupe id
Browse files Browse the repository at this point in the history
  • Loading branch information
llun committed Sep 4, 2024
1 parent 8b985f1 commit 922183c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions app/api/inbox/route.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 922183c

Please sign in to comment.