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:
17
server/queues/tasks/DeleteAttachmentTask.ts
Normal file
17
server/queues/tasks/DeleteAttachmentTask.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user