1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 12:42:44 +01:00

Redirect guild profile cdn stuff to normal avatar route while guild profiles are TODO

This commit is contained in:
Madeline 2022-07-17 16:54:26 +10:00
parent a1869d9723
commit 73af303bb4
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
3 changed files with 15 additions and 3 deletions

View File

@ -73,7 +73,7 @@ router.get("/:user_id", async (req: Request, res: Response) => {
return res.send(file);
});
router.get("/:user_id/:hash", async (req: Request, res: Response) => {
export const getAvatar = async (req: Request, res: Response) => {
var { user_id, hash } = req.params;
hash = hash.split(".")[0]; // remove .file extension
const path = `avatars/${user_id}/${hash}`;
@ -86,7 +86,9 @@ router.get("/:user_id/:hash", async (req: Request, res: Response) => {
res.set("Cache-Control", "public, max-age=31536000");
return res.send(file);
});
}
router.get("/:user_id/:hash", getAvatar);
router.delete("/:user_id/:id", async (req: Request, res: Response) => {
if (req.headers.signature !== Config.get().security.requestSignature)

10
cdn/src/routes/guilds.ts Normal file
View File

@ -0,0 +1,10 @@
import { Router } from "express";
import { getAvatar } from "./avatars";
const router = Router();
// TODO: handle guild profiles
router.get("/:guild_id/users/:user_id/avatars/:hash", getAvatar);
router.get("/:guild_id/users/:user_id/banners/:hash", getAvatar);
export default router;