mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* refactor: Add jobId hook to BaseTask for deduplicating queued jobs * fix: Drop jobId from APIImportTask, it re-schedules itself while active
35 lines
913 B
TypeScript
35 lines
913 B
TypeScript
import { IntegrationService } from "@shared/types";
|
|
import { BaseTask } from "@server/queues/tasks/base/BaseTask";
|
|
import { Hook, PluginManager } from "@server/utils/PluginManager";
|
|
|
|
type Props = {
|
|
headers: Record<string, unknown>;
|
|
payload: Record<string, unknown>;
|
|
};
|
|
|
|
export default class GitHubWebhookTask extends BaseTask<Props> {
|
|
protected jobId({ headers }: Props) {
|
|
const deliveryId = headers["x-github-delivery"];
|
|
return typeof deliveryId === "string"
|
|
? `github-webhook:${deliveryId}`
|
|
: undefined;
|
|
}
|
|
|
|
public async perform({ headers, payload }: Props): Promise<void> {
|
|
const plugins = PluginManager.getHooks(Hook.IssueProvider);
|
|
const plugin = plugins.find(
|
|
(p) => p.value.service === IntegrationService.GitHub
|
|
);
|
|
|
|
if (!plugin) {
|
|
return;
|
|
}
|
|
|
|
await plugin.value.handleWebhook({
|
|
headers,
|
|
payload,
|
|
teamId: null,
|
|
});
|
|
}
|
|
}
|