Merge pull request #382 from fosscord/auto-delete-relations

Auto delete relations
This commit is contained in:
Flam3rboy
2021-09-20 21:27:08 +02:00
committed by GitHub
29 changed files with 315 additions and 121 deletions
-12
View File
@@ -1,12 +0,0 @@
import { Attachment } from "@fosscord/util";
import { deleteFile } from "@fosscord/api";
import { URL } from "url";
export async function deleteMessageAttachments(messageId: string, keep?: Attachment[]) {
let attachments = await Attachment.find({ message_id: messageId });
if (keep)
attachments = attachments.filter(x => !keep.map(k => k.id).includes(x.id));
await Promise.all(attachments.map(a => a.remove()));
attachments.forEach(a => deleteFile((new URL(a.url)).pathname)); //We don't need to await since this is done on the cdn
}
-1
View File
@@ -1,5 +1,4 @@
export * from "./Base64";
export * from "./cdn";
export * from "./FieldError";
export * from "./ipAddress";
export * from "./Message";