summary refs log tree commit diff
path: root/api/src/util/cdn.ts
diff options
context:
space:
mode:
authorAlTech98 <altech123159@gmail.com>2021-09-13 17:32:31 +0200
committerAlTech98 <altech123159@gmail.com>2021-09-13 17:32:31 +0200
commitaa1f1a22a4cce0c51d84c10d5a741699f7bbfff2 (patch)
treef11c5005d4870739ec3be422a84f2aba532af4fd /api/src/util/cdn.ts
parentFix attachments not being saved to db (diff)
downloadserver-aa1f1a22a4cce0c51d84c10d5a741699f7bbfff2.tar.xz
Delete attachments of deleted messages, fix #273
Diffstat (limited to '')
-rw-r--r--api/src/util/cdn.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/api/src/util/cdn.ts b/api/src/util/cdn.ts

index 3c71d980..88b0ea0d 100644 --- a/api/src/util/cdn.ts +++ b/api/src/util/cdn.ts
@@ -38,3 +38,16 @@ export async function handleFile(path: string, body?: string): Promise<string | throw new HTTPError("Invalid " + path); } } + +export async function deleteFile(path: string) { + const response = await fetch(`${Config.get().cdn.endpoint || "http://localhost:3003"}${path}`, { + headers: { + signature: Config.get().security.requestSignature, + }, + method: "DELETE", + }); + const result = await response.json(); + + if (response.status !== 200) throw result; + return result; +}