summary refs log tree commit diff
path: root/api/src/util/Attachments.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-19 18:46:22 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-19 18:46:22 +0200
commit313696d237cc614cca8f68d8a63ad3039d00baf9 (patch)
treeffee7dd8d0bcfd4fda2ad5c14238003d49b74f68 /api/src/util/Attachments.ts
parent:bug: fix bundle debug (diff)
downloadserver-313696d237cc614cca8f68d8a63ad3039d00baf9.tar.xz
:art: remove deleteMessageAttachments and move to entity
Diffstat (limited to 'api/src/util/Attachments.ts')
-rw-r--r--api/src/util/Attachments.ts12
1 files changed, 0 insertions, 12 deletions
diff --git a/api/src/util/Attachments.ts b/api/src/util/Attachments.ts
deleted file mode 100644

index addda97f..00000000 --- a/api/src/util/Attachments.ts +++ /dev/null
@@ -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 -}