summary refs log tree commit diff
path: root/api/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-20 21:27:08 +0200
committerGitHub <noreply@github.com>2021-09-20 21:27:08 +0200
commitfe34c5da8747022ce568ea43deb002fade3b5faa (patch)
tree6ebbfa513b52428562138cc8b765c41f86f137ee /api/src/util
parentMerge pull request #386 from ChrisChrome/master (diff)
parent:bug: fix .delete -> add onDelete: "CASCADE" (diff)
downloadserver-fe34c5da8747022ce568ea43deb002fade3b5faa.tar.xz
Merge pull request #382 from fosscord/auto-delete-relations
Auto delete relations
Diffstat (limited to 'api/src/util')
-rw-r--r--api/src/util/Attachments.ts12
-rw-r--r--api/src/util/index.ts1
2 files changed, 0 insertions, 13 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 -} diff --git a/api/src/util/index.ts b/api/src/util/index.ts
index 4b1e8e77..3e47ce4e 100644 --- a/api/src/util/index.ts +++ b/api/src/util/index.ts
@@ -1,5 +1,4 @@ export * from "./Base64"; -export * from "./cdn"; export * from "./FieldError"; export * from "./ipAddress"; export * from "./Message";