diff --git a/src/cdn/routes/app-assets.ts b/src/cdn/routes/app-assets.ts index 149d8b351..0764d5201 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 b67bc1fb0..300d4bdaa 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 f2d539bdc..9fc74bf69 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 979bdad02..89bd8bc06 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 3b85d4e46..587a09644 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 e9c07cb19..ee6e0af53 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 9d6d81c70..32dfb9b22 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 f11af3bad..074e727d7 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 9d27debf3..d96a6ddcc 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 6ddd49e9d..727497f88 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 a10709d71..44626dc76 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 a92069493..2ffa92fc4 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 c0e7e7854..de5f02254 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 7490d5465..1d2f76b7a 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");