Files
outline/server/queues/tasks/DeleteAttachmentTask.ts
2024-03-19 18:57:15 -04:00

31 lines
584 B
TypeScript

import { Attachment } from "@server/models";
import BaseTask, { TaskPriority } from "./BaseTask";
type Props = {
teamId: string;
attachmentId: string;
};
export default class DeleteAttachmentTask extends BaseTask<Props> {
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,
};
}
}