mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 06:32:34 +00:00
add support for desktop/web
This commit is contained in:
7 files changed
+11
-1
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Generated
BIN
Binary file not shown.
+11
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user