summary refs log tree commit diff
path: root/src/cdn/routes/guild-profiles.ts
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
commit0a8ceb9e6349284e75545a01ffad608b020f78e2 (patch)
tree17a9163f963eddabf9168b0b630096b2f7535b64 /src/cdn/routes/guild-profiles.ts
parentPrettier: use editorconfig (diff)
downloadserver-0a8ceb9e6349284e75545a01ffad608b020f78e2.tar.xz
Actually run prettier dev/emma-refactors
Diffstat (limited to 'src/cdn/routes/guild-profiles.ts')
-rw-r--r--src/cdn/routes/guild-profiles.ts16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts
index 1ee5eeca..01377b9d 100644
--- a/src/cdn/routes/guild-profiles.ts
+++ b/src/cdn/routes/guild-profiles.ts
@@ -30,13 +30,7 @@ import { storage } from "../util/Storage";
 // TODO: delete old icons
 
 const ANIMATED_MIME_TYPES = ["image/apng", "image/gif", "image/gifv"];
-const STATIC_MIME_TYPES = [
-	"image/png",
-	"image/jpeg",
-	"image/webp",
-	"image/svg+xml",
-	"image/svg",
-];
+const STATIC_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/svg"];
 const ALLOWED_MIME_TYPES = [...ANIMATED_MIME_TYPES, ...STATIC_MIME_TYPES];
 
 const router = Router();
@@ -48,14 +42,10 @@ router.post("/", multer.single("file"), async (req: Request, res: Response) => {
 	const { buffer, size } = req.file;
 	const { guild_id, user_id } = req.params;
 
-	let hash = crypto
-		.createHash("md5")
-		.update(Snowflake.generate())
-		.digest("hex");
+	let hash = crypto.createHash("md5").update(Snowflake.generate()).digest("hex");
 
 	const type = await FileType.fromBuffer(buffer);
-	if (!type || !ALLOWED_MIME_TYPES.includes(type.mime))
-		throw new HTTPError("Invalid file type");
+	if (!type || !ALLOWED_MIME_TYPES.includes(type.mime)) throw new HTTPError("Invalid file type");
 	if (ANIMATED_MIME_TYPES.includes(type.mime)) hash = `a_${hash}`; // animated icons have a_ infront of the hash
 
 	const path = `guilds/${guild_id}/users/${user_id}/avatars/${hash}`;