summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-29 10:40:45 +0200
committerGitHub <noreply@github.com>2024-08-29 10:40:45 +0200
commit1d98b2ff5bd65fb4704c70edcd3786e71a6620a0 (patch)
tree8bcff7aa7790c4182bc1a201d8a4b8e3aee9b049 /src/api
parentFixes for password, mfa code & email validation (diff)
parentMerge pull request #1201 from CyberL1/fix/pins (diff)
downloadserver-ts-1d98b2ff5bd65fb4704c70edcd3786e71a6620a0.tar.xz
Merge branch 'master' into fix/password-mfacode-schemas
Diffstat (limited to 'src/api')
-rw-r--r--src/api/middlewares/Authentication.ts2
-rw-r--r--src/api/middlewares/ImageProxy.ts9
-rw-r--r--src/api/routes/channels/#channel_id/pins.ts1
3 files changed, 10 insertions, 2 deletions
diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts

index ffefee8fb..ec77cbbb8 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts
@@ -54,6 +54,8 @@ export const NO_AUTHORIZATION_ROUTES = [ /GET \/guilds\/\d+\/widget\.(json|png)/, // Connections /POST \/connections\/\w+\/callback/, + // Image proxy + /GET \/imageproxy\/[A-Za-z0-9+/]\/\d+x\d+\/.+/, ]; export const API_PREFIX = /^\/api(\/v\d+)?/; diff --git a/src/api/middlewares/ImageProxy.ts b/src/api/middlewares/ImageProxy.ts
index 537c5da17..4f9eef10c 100644 --- a/src/api/middlewares/ImageProxy.ts +++ b/src/api/middlewares/ImageProxy.ts
@@ -67,7 +67,12 @@ export async function ImageProxy(req: Request, res: Response) { if (!crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(path[0]))) throw new Error("Invalid signature"); } catch { - console.log("Invalid signature, expected " + hash + " got " + path[0]); + console.log( + "[ImageProxy] Invalid signature, expected " + + hash + + " but got " + + path[0], + ); res.status(403).send("Invalid signature"); return; } @@ -75,7 +80,7 @@ export async function ImageProxy(req: Request, res: Response) { const abort = new AbortController(); setTimeout(() => abort.abort(), 5000); - const request = await fetch(path.slice(2).join("/"), { + const request = await fetch("https://" + path.slice(2).join("/"), { headers: { "User-Agent": "SpacebarImageProxy/1.0.0 (https://spacebar.chat)", }, diff --git a/src/api/routes/channels/#channel_id/pins.ts b/src/api/routes/channels/#channel_id/pins.ts
index d43db6ecc..f9586469e 100644 --- a/src/api/routes/channels/#channel_id/pins.ts +++ b/src/api/routes/channels/#channel_id/pins.ts
@@ -179,6 +179,7 @@ router.get( const pins = await Message.find({ where: { channel_id: channel_id, pinned: true }, + relations: ["author"], }); res.send(pins);