fix: Allow viewers to upload avatar (#4349)

* fix: Allow viewers to upload avatar

* DeleteAttachmentTask

* fix: Previous avatar should be deleted on change, if possible

* fix: Also cleanup team logo on change
This commit is contained in:
Tom Moor
2022-10-29 09:08:20 -04:00
committed by GitHub
parent 19e26ba402
commit 79cbe304da
7 changed files with 191 additions and 65 deletions

View File

@@ -0,0 +1,17 @@
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();
}
}