From 1189deaa7cac6b8d5860e1cbdd83b8fa9feb744b Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 17 Feb 2023 19:59:12 -0500 Subject: add support for desktop/web --- src/cdn/routes/embed.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') 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