Files
outline/server/queues/tasks/DeleteAttachmentTask.ts
Tom Moor bc992fb22a refactor: Add jobId hook to BaseTask for deduplicating queued jobs (#13890)
* refactor: Add jobId hook to BaseTask for deduplicating queued jobs

* fix: Drop jobId from APIImportTask, it re-schedules itself while active
2026-09-25 23:44:16 +00:00

35 lines
687 B
TypeScript

import { Attachment } from "@server/models";
import { BaseTask, TaskPriority } from "./base/BaseTask";
type Props = {
teamId: string;
attachmentId: string;
};
export default class DeleteAttachmentTask extends BaseTask<Props> {
protected jobId({ attachmentId }: Props) {
return `delete-attachment:${attachmentId}`;
}
public async perform({ attachmentId, teamId }: Props) {
const attachment = await Attachment.findOne({
where: {
teamId,
id: attachmentId,
},
});
if (!attachment) {
return;
}
await attachment.destroy();
}
public get options() {
return {
priority: TaskPriority.Background,
};
}
}