From ebe2ff0e215b76aa64ad17c4567eb970698e8d75 Mon Sep 17 00:00:00 2001 From: mia Date: Tue, 5 Nov 2024 16:29:52 -0700 Subject: [PATCH] fix replacements crashing on delivering poll votes --- .../backend/src/queue/processors/deliver.ts | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/backend/src/queue/processors/deliver.ts b/packages/backend/src/queue/processors/deliver.ts index 7518a3ca9..a718fe291 100644 --- a/packages/backend/src/queue/processors/deliver.ts +++ b/packages/backend/src/queue/processors/deliver.ts @@ -36,24 +36,26 @@ export default async (job: Bull.Job) => { logger.debug(`delivering ${latest}`); } - let i = undefined; - - if ( - ["Create", "Update"].includes(job.data.content.type) - && job.data.content.object.type === "Note" - ) { - const obj = job.data.content.object; - const patchSrcContent = shouldPatchText(obj.source.content); - if (patchSrcContent) { - i = await registerOrFetchInstanceDoc(host); - if (shouldPatchText(obj.content)) - obj.content = patchText(obj.content, i); - if (shouldPatchText(obj._misskey_content)) - obj._misskey_content = patchText(obj._misskey_content, i); - if (patchSrcContent) - obj.source.content = patchText(obj.source.content, i); - } - } + let i = undefined; + + if ( + ["Create", "Update"].includes(job.data.content.type) + && job.data.content.object.type === "Note" + && job.data.content.object.content + ) { + const obj = job.data.content.object; + const patchSrcContent = shouldPatchText(obj.source.content); + if (patchSrcContent) { + i = await registerOrFetchInstanceDoc(host); + if (shouldPatchText(obj.content)) + obj.content = patchText(obj.content, i); + if (shouldPatchText(obj._misskey_content)) + obj._misskey_content = patchText(obj._misskey_content, i); + if (patchSrcContent) + obj.source.content = patchText(obj.source.content, i); + } + } + await request(job.data.user, job.data.to, job.data.content);