From ea28dc46ebf775f30c8df9c401157262d59f113b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 26 Jul 2022 22:33:48 +0100 Subject: [PATCH] fix: Error in WebhookProcessor when team is permanatly destroyed --- server/commands/starCreator.ts | 6 +++--- server/queues/processors/WebhookProcessor.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/commands/starCreator.ts b/server/commands/starCreator.ts index 02a55bae9..cdf960b61 100644 --- a/server/commands/starCreator.ts +++ b/server/commands/starCreator.ts @@ -54,7 +54,7 @@ export default async function starCreator({ index = fractionalIndex(null, stars.length ? stars[0].index : null); } - const response = await Star.findOrCreate({ + const [star, isCreated] = await Star.findOrCreate({ where: documentId ? { userId: user.id, @@ -69,12 +69,12 @@ export default async function starCreator({ }, transaction, }); - const star = response[0]; - if (response[1]) { + if (isCreated) { await Event.create( { name: "stars.create", + teamId: user.teamId, modelId: star.id, userId: user.id, actorId: user.id, diff --git a/server/queues/processors/WebhookProcessor.ts b/server/queues/processors/WebhookProcessor.ts index cb9393b80..3f0f4f12e 100644 --- a/server/queues/processors/WebhookProcessor.ts +++ b/server/queues/processors/WebhookProcessor.ts @@ -7,6 +7,10 @@ export default class WebhookProcessor extends BaseProcessor { static applicableEvents: ["*"] = ["*"]; async perform(event: Event) { + if (!event.teamId) { + return; + } + const webhookSubscriptions = await WebhookSubscription.findAll({ where: { enabled: true,