summary refs log tree commit diff
path: root/src/cdn/routes/role-icons.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/cdn/routes/role-icons.ts')
-rw-r--r--src/cdn/routes/role-icons.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts
index 768e194f..b0946eaa 100644
--- a/src/cdn/routes/role-icons.ts
+++ b/src/cdn/routes/role-icons.ts
@@ -17,8 +17,9 @@ const ALLOWED_MIME_TYPES = [...STATIC_MIME_TYPES];
 const router = Router();
 
 router.post("/:role_id", multer.single("file"), async (req: Request, res: Response) => {
-	if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature");
-	if (!req.file) throw new HTTPError("Missing file");
+	if (req.headers.signature !== Config.get().security.requestSignature)
+		throw new HTTPError(req.t("common:body.INVALID_REQUEST_SIGNATURE"));
+	if (!req.file) throw new HTTPError(req.t("common:body.MISSING_FILE"));
 	const { buffer, mimetype, size, originalname, fieldname } = req.file;
 	const { role_id } = req.params;
 
@@ -46,7 +47,7 @@ router.get("/:role_id", async (req: Request, res: Response) => {
 	const path = `role-icons/${role_id}`;
 
 	const file = await storage.get(path);
-	if (!file) throw new HTTPError("not found", 404);
+	if (!file) throw new HTTPError(req.t("common:notfound.FILE"), 404);
 	const type = await FileType.fromBuffer(file);
 
 	res.set("Content-Type", type?.mime);
@@ -61,7 +62,7 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => {
 	const path = `role-icons/${role_id}/${hash}`;
 
 	const file = await storage.get(path);
-	if (!file) throw new HTTPError("not found", 404);
+	if (!file) throw new HTTPError(req.t("common:notfound.FILE"), 404);
 	const type = await FileType.fromBuffer(file);
 
 	res.set("Content-Type", type?.mime);
@@ -71,7 +72,8 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => {
 });
 
 router.delete("/:role_id/:id", async (req: Request, res: Response) => {
-	if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature");
+	if (req.headers.signature !== Config.get().security.requestSignature)
+		throw new HTTPError(req.t("common:body.INVALID_REQUEST_SIGNATURE"));
 	const { role_id, id } = req.params;
 	const path = `role-icons/${role_id}/${id}`;