fix: Error in WebhookProcessor when team is permanatly destroyed

This commit is contained in:
Tom Moor
2022-07-26 22:33:48 +01:00
parent 2794057738
commit ea28dc46eb
2 changed files with 7 additions and 3 deletions

View File

@@ -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,

View File

@@ -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,