* fix: Allow viewers to upload avatar * DeleteAttachmentTask * fix: Previous avatar should be deleted on change, if possible * fix: Also cleanup team logo on change
18 lines
388 B
TypeScript
18 lines
388 B
TypeScript
import { Attachment } from "@server/models";
|
|
import BaseTask from "./BaseTask";
|
|
|
|
type Props = {
|
|
attachmentId: string;
|
|
};
|
|
|
|
export default class DeleteAttachmentTask extends BaseTask<Props> {
|
|
public async perform({ attachmentId }: Props) {
|
|
const attachment = await Attachment.findByPk(attachmentId);
|
|
if (!attachment) {
|
|
return;
|
|
}
|
|
|
|
await attachment.destroy();
|
|
}
|
|
}
|