mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
* Update task scheduling to use instance method * Delete update_task_schedule.sh * Applied automatic fixes * tsc --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
35 lines
894 B
TypeScript
35 lines
894 B
TypeScript
import { WebhookSubscription } from "@server/models";
|
|
import BaseProcessor from "@server/queues/processors/BaseProcessor";
|
|
import { Event } from "@server/types";
|
|
import DeliverWebhookTask from "../tasks/DeliverWebhookTask";
|
|
|
|
export default class WebhookProcessor extends BaseProcessor {
|
|
static applicableEvents: ["*"] = ["*"];
|
|
|
|
async perform(event: Event) {
|
|
if (!event.teamId) {
|
|
return;
|
|
}
|
|
|
|
const webhookSubscriptions = await WebhookSubscription.findAll({
|
|
where: {
|
|
enabled: true,
|
|
teamId: event.teamId,
|
|
},
|
|
});
|
|
|
|
const applicableSubscriptions = webhookSubscriptions.filter((webhook) =>
|
|
webhook.validForEvent(event)
|
|
);
|
|
|
|
await Promise.all(
|
|
applicableSubscriptions.map((subscription) =>
|
|
new DeliverWebhookTask().schedule({
|
|
event,
|
|
subscriptionId: subscription.id,
|
|
})
|
|
)
|
|
);
|
|
}
|
|
}
|