summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-19 08:18:16 +0100
committerRory& <root@rory.gay>2026-03-19 08:18:16 +0100
commitb839c0a2c459cd2edc5e9c0136ebd29455b83ca7 (patch)
tree77c3a87e08bd40b6c25017cdd6bb6d27db7e5a74
parentFix typing for activity metadata (diff)
downloadserver-ts-b839c0a2c459cd2edc5e9c0136ebd29455b83ca7.tar.xz
CDN: use file contents for hashes, the fuck
-rw-r--r--src/cdn/routes/app-assets.ts2
-rw-r--r--src/cdn/routes/app-icons.ts2
-rw-r--r--src/cdn/routes/avatars.ts2
-rw-r--r--src/cdn/routes/banners.ts2
-rw-r--r--src/cdn/routes/channel-icons.ts2
-rw-r--r--src/cdn/routes/discover-splashes.ts2
-rw-r--r--src/cdn/routes/discovery-splashes.ts2
-rw-r--r--src/cdn/routes/emojis.ts2
-rw-r--r--src/cdn/routes/guild-profiles.ts2
-rw-r--r--src/cdn/routes/icons.ts2
-rw-r--r--src/cdn/routes/splashes.ts2
-rw-r--r--src/cdn/routes/stickers.ts2
-rw-r--r--src/cdn/routes/team-icons.ts2
-rw-r--r--src/cdn/util/basicCrdFileRouter.ts2
14 files changed, 14 insertions, 14 deletions
diff --git a/src/cdn/routes/app-assets.ts b/src/cdn/routes/app-assets.ts

index 149d8b35..0764d520 100644 --- a/src/cdn/routes/app-assets.ts +++ b/src/cdn/routes/app-assets.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/app-icons.ts b/src/cdn/routes/app-icons.ts
index b67bc1fb..300d4bda 100644 --- a/src/cdn/routes/app-icons.ts +++ b/src/cdn/routes/app-icons.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts
index f2d539bd..9fc74bf6 100644 --- a/src/cdn/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts
@@ -42,7 +42,7 @@ router.post("/:user_id", multer.single("file"), async (req: Request, res: Respon const { buffer, size } = req.file; const { user_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/banners.ts b/src/cdn/routes/banners.ts
index 979bdad0..89bd8bc0 100644 --- a/src/cdn/routes/banners.ts +++ b/src/cdn/routes/banners.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/channel-icons.ts b/src/cdn/routes/channel-icons.ts
index 3b85d4e4..587a0964 100644 --- a/src/cdn/routes/channel-icons.ts +++ b/src/cdn/routes/channel-icons.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/discover-splashes.ts b/src/cdn/routes/discover-splashes.ts
index e9c07cb1..ee6e0af5 100644 --- a/src/cdn/routes/discover-splashes.ts +++ b/src/cdn/routes/discover-splashes.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/discovery-splashes.ts b/src/cdn/routes/discovery-splashes.ts
index 9d6d81c7..32dfb9b2 100644 --- a/src/cdn/routes/discovery-splashes.ts +++ b/src/cdn/routes/discovery-splashes.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/emojis.ts b/src/cdn/routes/emojis.ts
index f11af3ba..074e727d 100644 --- a/src/cdn/routes/emojis.ts +++ b/src/cdn/routes/emojis.ts
@@ -43,7 +43,7 @@ router.post("/:emoji_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { emoji_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts
index 9d27debf..d96a6ddc 100644 --- a/src/cdn/routes/guild-profiles.ts +++ b/src/cdn/routes/guild-profiles.ts
@@ -42,7 +42,7 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => { const { buffer, size } = req.file; const { guild_id, user_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/icons.ts b/src/cdn/routes/icons.ts
index 6ddd49e9..727497f8 100644 --- a/src/cdn/routes/icons.ts +++ b/src/cdn/routes/icons.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/splashes.ts b/src/cdn/routes/splashes.ts
index a10709d7..44626dc7 100644 --- a/src/cdn/routes/splashes.ts +++ b/src/cdn/routes/splashes.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/stickers.ts b/src/cdn/routes/stickers.ts
index a9206949..2ffa92fc 100644 --- a/src/cdn/routes/stickers.ts +++ b/src/cdn/routes/stickers.ts
@@ -43,7 +43,7 @@ router.post("/:sticker_id", multer.single("file"), async (req: Request, res: Res const { buffer, size } = req.file; const { sticker_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/routes/team-icons.ts b/src/cdn/routes/team-icons.ts
index c0e7e785..de5f0225 100644 --- a/src/cdn/routes/team-icons.ts +++ b/src/cdn/routes/team-icons.ts
@@ -43,7 +43,7 @@ router.post("/:guild_id", multer.single("file"), async (req: Request, res: Respo const { buffer, size } = req.file; const { guild_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type"); diff --git a/src/cdn/util/basicCrdFileRouter.ts b/src/cdn/util/basicCrdFileRouter.ts
index 7490d546..1d2f76b7 100644 --- a/src/cdn/util/basicCrdFileRouter.ts +++ b/src/cdn/util/basicCrdFileRouter.ts
@@ -51,7 +51,7 @@ export function createBasicCrdFileRouter(opts: BasicCrdFileRouterOptions) { const { buffer, size } = req.file; const { user_id } = req.params as { [key: string]: string }; - let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex"); + let hash = crypto.createHash("md5").update(buffer).digest("hex"); const type = await fileTypeFromBuffer(buffer); if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type");