From 40267c11162cf67eb6b4e2be3d3ac877f6286299 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Wed, 7 Jun 2023 09:16:41 -0400 Subject: [PATCH] fix inbox stall --- packages/backend/src/queue/processors/inbox.ts | 3 +++ packages/backend/src/services/note/create.ts | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index ca063a6f3..b319fbd38 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -34,6 +34,9 @@ export default async (job: Bull.Job): Promise => { const info = Object.assign({}, activity) as any; info["@context"] = undefined; logger.debug(JSON.stringify(info, null, 2)); + + if (!signature?.keyId) return `Invalid signature: ${signature}`; + //#endregion const host = toPuny(new URL(signature.keyId).hostname); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index abb8d94e8..ab3f36570 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -718,14 +718,23 @@ async function insertNote( if (insert.hasPoll) { // Start transaction await db.transaction(async (transactionalEntityManager) => { + if (!data.poll) throw new Error("Empty poll data"); + await transactionalEntityManager.insert(Note, insert); + let expiresAt: Date | null; + if (!data.poll.expiresAt || isNaN(data.poll.expiresAt.getTime())) { + expiresAt = null; + } else { + expiresAt = data.poll.expiresAt; + } + const poll = new Poll({ noteId: insert.id, - choices: data.poll!.choices, - expiresAt: data.poll!.expiresAt, - multiple: data.poll!.multiple, - votes: new Array(data.poll!.choices.length).fill(0), + choices: data.poll.choices, + expiresAt, + multiple: data.poll.multiple, + votes: new Array(data.poll.choices.length).fill(0), noteVisibility: insert.visibility, userId: user.id, userHost: user.host,