diff options
Diffstat (limited to 'api/src/util')
-rw-r--r-- | api/src/util/Attachments.ts | 12 | ||||
-rw-r--r-- | api/src/util/cdn.ts | 4 | ||||
-rw-r--r-- | api/src/util/index.ts | 1 | ||||
-rw-r--r-- | api/src/util/route.ts | 1 |
4 files changed, 3 insertions, 15 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/cdn.ts b/api/src/util/cdn.ts index 88b0ea0d..8c6e9ac9 100644 --- a/api/src/util/cdn.ts +++ b/api/src/util/cdn.ts @@ -42,9 +42,9 @@ export async function handleFile(path: string, body?: string): Promise<string | export async function deleteFile(path: string) { const response = await fetch(`${Config.get().cdn.endpoint || "http://localhost:3003"}${path}`, { headers: { - signature: Config.get().security.requestSignature, + signature: Config.get().security.requestSignature }, - method: "DELETE", + method: "DELETE" }); const result = await response.json(); 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"; diff --git a/api/src/util/route.ts b/api/src/util/route.ts index 9ef92c3a..5b06a2b5 100644 --- a/api/src/util/route.ts +++ b/api/src/util/route.ts @@ -14,6 +14,7 @@ export const ajv = new Ajv({ parseDate: true, allowDate: true, schemas, + coerceTypes: true, messages: true, strict: true, strictRequired: true |