From fb52929599f91c5cc74062d0fed50b731385ee27 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 17 Feb 2023 19:59:12 -0500 Subject: add support for desktop/web --- assets/default-avatars/1.png | Bin 4397 -> 0 bytes assets/default-avatars/2.png | Bin 4544 -> 0 bytes assets/default-avatars/3.png | Bin 2831 -> 0 bytes assets/default-avatars/4.png | Bin 2855 -> 0 bytes assets/default-avatars/5.png | Bin 4276 -> 0 bytes assets/public/1f0bfc0865d324c2587920a7d80c609b.png | Bin 0 -> 4397 bytes assets/public/3c6ccb83716d1e4fb91d3082f6b21d77.png | Bin 0 -> 4276 bytes assets/public/6f26ddd1bf59740c536d2274bb834a05.png | Bin 0 -> 2855 bytes assets/public/7c8f476123d28d103efe381543274c25.png | Bin 0 -> 2831 bytes assets/public/c09a43a372ba81e3018c3151d4ed4773.png | Bin 0 -> 4544 bytes package-lock.json | 1 - src/cdn/routes/embed.ts | 12 +++++++++++- 12 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 assets/default-avatars/1.png delete mode 100644 assets/default-avatars/2.png delete mode 100644 assets/default-avatars/3.png delete mode 100644 assets/default-avatars/4.png delete mode 100644 assets/default-avatars/5.png create mode 100644 assets/public/1f0bfc0865d324c2587920a7d80c609b.png create mode 100644 assets/public/3c6ccb83716d1e4fb91d3082f6b21d77.png create mode 100644 assets/public/6f26ddd1bf59740c536d2274bb834a05.png create mode 100644 assets/public/7c8f476123d28d103efe381543274c25.png create mode 100644 assets/public/c09a43a372ba81e3018c3151d4ed4773.png diff --git a/assets/default-avatars/1.png b/assets/default-avatars/1.png deleted file mode 100644 index 61b3f9cf..00000000 Binary files a/assets/default-avatars/1.png and /dev/null differ diff --git a/assets/default-avatars/2.png b/assets/default-avatars/2.png deleted file mode 100644 index 8caebf90..00000000 Binary files a/assets/default-avatars/2.png and /dev/null differ diff --git a/assets/default-avatars/3.png b/assets/default-avatars/3.png deleted file mode 100644 index 3fadcedf..00000000 Binary files a/assets/default-avatars/3.png and /dev/null differ diff --git a/assets/default-avatars/4.png b/assets/default-avatars/4.png deleted file mode 100644 index bcf0c183..00000000 Binary files a/assets/default-avatars/4.png and /dev/null differ diff --git a/assets/default-avatars/5.png b/assets/default-avatars/5.png deleted file mode 100644 index 3cc5589c..00000000 Binary files a/assets/default-avatars/5.png and /dev/null differ diff --git a/assets/public/1f0bfc0865d324c2587920a7d80c609b.png b/assets/public/1f0bfc0865d324c2587920a7d80c609b.png new file mode 100644 index 00000000..61b3f9cf Binary files /dev/null and b/assets/public/1f0bfc0865d324c2587920a7d80c609b.png differ diff --git a/assets/public/3c6ccb83716d1e4fb91d3082f6b21d77.png b/assets/public/3c6ccb83716d1e4fb91d3082f6b21d77.png new file mode 100644 index 00000000..3cc5589c Binary files /dev/null and b/assets/public/3c6ccb83716d1e4fb91d3082f6b21d77.png differ diff --git a/assets/public/6f26ddd1bf59740c536d2274bb834a05.png b/assets/public/6f26ddd1bf59740c536d2274bb834a05.png new file mode 100644 index 00000000..bcf0c183 Binary files /dev/null and b/assets/public/6f26ddd1bf59740c536d2274bb834a05.png differ diff --git a/assets/public/7c8f476123d28d103efe381543274c25.png b/assets/public/7c8f476123d28d103efe381543274c25.png new file mode 100644 index 00000000..3fadcedf Binary files /dev/null and b/assets/public/7c8f476123d28d103efe381543274c25.png differ diff --git a/assets/public/c09a43a372ba81e3018c3151d4ed4773.png b/assets/public/c09a43a372ba81e3018c3151d4ed4773.png new file mode 100644 index 00000000..8caebf90 Binary files /dev/null and b/assets/public/c09a43a372ba81e3018c3151d4ed4773.png differ diff --git a/package-lock.json b/package-lock.json index 165a2b23..ecd455b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,6 @@ "probe-image-size": "^7.2.3", "proxy-agent": "^5.0.0", "reflect-metadata": "^0.1.13", - "sqlite3": "*", "ts-node": "^10.9.1", "tslib": "^2.4.1", "typeorm": "^0.3.10", diff --git a/src/cdn/routes/embed.ts b/src/cdn/routes/embed.ts index c38046ed..5e5ff76d 100644 --- a/src/cdn/routes/embed.ts +++ b/src/cdn/routes/embed.ts @@ -22,6 +22,14 @@ import fs from "fs/promises"; import { HTTPError } from "lambert-server"; import { join } from "path"; +const defaultAvatarHashMap = new Map([ + ["1", "1f0bfc0865d324c2587920a7d80c609b"], + ["2", "c09a43a372ba81e3018c3151d4ed4773"], + ["3", "7c8f476123d28d103efe381543274c25"], + ["4", "6f26ddd1bf59740c536d2274bb834a05"], + ["5", "3c6ccb83716d1e4fb91d3082f6b21d77"], +]); + const router = Router(); async function getFile(path: string) { @@ -41,7 +49,9 @@ async function getFile(path: string) { router.get("/avatars/:id", async (req: Request, res: Response) => { let { id } = req.params; id = id.split(".")[0]; // remove .file extension - const path = join(process.cwd(), "assets", "default-avatars", `${id}.png`); + const hash = defaultAvatarHashMap.get(id); + if (!hash) throw new HTTPError("not found", 404); + const path = join(process.cwd(), "assets", "public", `${hash}.png`); const file = await getFile(path); if (!file) throw new HTTPError("not found", 404); -- cgit 1.4.1