1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-19 17:21:35 +02:00

add support for desktop/web

This commit is contained in:
Puyodead1 2023-02-17 19:59:12 -05:00
parent 3aae202e19
commit fb52929599
No known key found for this signature in database
GPG Key ID: BA5F91AAEF68E5CE
7 changed files with 11 additions and 2 deletions

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

1
package-lock.json generated
View File

@ -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",

View File

@ -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);