diff --git a/assets/locales/en/auth.json b/assets/locales/en/auth.json
index 2178548e..dc4358f1 100644
--- a/assets/locales/en/auth.json
+++ b/assets/locales/en/auth.json
@@ -15,6 +15,10 @@
"CONSENT_REQUIRED": "You must agree to the Terms of Service and Privacy Policy.",
"USERNAME_TOO_MANY_USERS": "Too many users have this username, please try another",
"GUESTS_DISABLED": "Guest users are disabled",
- "TOO_MANY_REGISTRATIONS": "Too many registrations, please try again later"
+ "TOO_MANY_REGISTRATIONS": "Too many registrations, please try again later",
+ "IP_BLOCKED": "Your IP is blocked from registration"
+ },
+ "generic": {
+ "MISSING_AUTH_HEADER": "Missing Authorization Header"
}
}
diff --git a/assets/locales/en/common.json b/assets/locales/en/common.json
index 8bb9c042..99f553cc 100644
--- a/assets/locales/en/common.json
+++ b/assets/locales/en/common.json
@@ -14,5 +14,28 @@
"EMAIL_TYPE_INVALID_EMAIL": "Not a well-formed email address",
"DATE_TYPE_PARSE": "Could not parse {{date}}. Should be ISO8601",
"BASE_TYPE_BAD_LENGTH": "Must be between {{length}} in length"
+ },
+ "body": {
+ "INVALID_BODY": "Invalid Body",
+ "INVALID_REQUEST_SIGNATURE": "Invalid request signature",
+ "MISSING_FILE": "File missing",
+ "INVALID_FILE_TYPE": "Invalid file type"
+ },
+ "notfound": {
+ "CHANNEL": "This channel doesn't exist",
+ "USER": "User not found",
+ "ROLE": "Role not found",
+ "REACTION": "Reaction not found",
+ "FILE": "File not found"
+ },
+ "relationship": {
+ "ALREADY_BLOCKED": "You already blocked the user",
+ "NOT_FRIENDS": "You are not friends with the user",
+ "ALREADY_FRIENDS": "You are already friends with the user",
+ "ALREADY_SENT": "You already sent a friend request",
+ "ADD_SELF": "You can't add yourself as a friend",
+ "REMOVE_SELF": "You can't remove yourself as a friend",
+ "UNBLOCK": "Unblock the user before sending a friend request",
+ "BLOCKED": "The user blocked you"
}
}
diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts
index 6d063953..fbf71cd5 100644
--- a/src/api/middlewares/Authentication.ts
+++ b/src/api/middlewares/Authentication.ts
@@ -53,7 +53,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc
})
)
return next();
- if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401));
+ if (!req.headers.authorization) return next(new HTTPError(req.t("auth:generic.MISSING_AUTH_HEADER"), 401));
try {
const { jwtSecret } = Config.get().security;
diff --git a/src/api/middlewares/BodyParser.ts b/src/api/middlewares/BodyParser.ts
index 36d89da7..b7c99638 100644
--- a/src/api/middlewares/BodyParser.ts
+++ b/src/api/middlewares/BodyParser.ts
@@ -11,7 +11,7 @@ export function BodyParser(opts?: OptionsJson) {
jsonParser(req, res, (err) => {
if (err) {
// TODO: different errors for body parser (request size limit, wrong body type, invalid body, ...)
- return next(new HTTPError("Invalid Body", 400));
+ return next(new HTTPError(req.t("common:body.INVALID_BODY"), 400));
}
next();
});
diff --git a/src/api/routes/auth/logout.ts b/src/api/routes/auth/logout.ts
new file mode 100644
index 00000000..b54be044
--- /dev/null
+++ b/src/api/routes/auth/logout.ts
@@ -0,0 +1,19 @@
+import { route } from "@fosscord/api";
+import { Request, Response, Router } from "express";
+
+
+const router: Router = Router();
+export default router;
+
+router.post("/", route({}), async (req: Request, res: Response) => {
+ if(req.body.provider != null || req.body.voip_provider != null) {
+ console.log(`[LOGOUT]: provider or voip provider not null!`, req.body);
+ }
+ else {
+ delete req.body.provider;
+ delete req.body.voip_provider;
+ if(Object.keys(req.body).length != 0)
+ console.log(`[LOGOUT]: Extra fields sent in logout!`, req.body);
+ }
+ res.status(204).send();
+});
\ No newline at end of file
diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index 3a1d2666..5fb8f5df 100644
--- a/src/api/routes/channels/#channel_id/invites.ts
+++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -15,7 +15,7 @@ router.post(
isTextChannel(channel.type);
if (!channel.guild_id) {
- throw new HTTPError("This channel doesn't exist", 404);
+ throw new HTTPError(req.t("common:notfound.CHANNEL"), 404);
}
const { guild_id } = channel;
@@ -46,7 +46,7 @@ router.get("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request, r
const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
if (!channel.guild_id) {
- throw new HTTPError("This channel doesn't exist", 404);
+ throw new HTTPError(req.t("common:notfound.CHANNEL"), 404);
}
const { guild_id } = channel;
diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
index 44de5c45..f13f5f94 100644
--- a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
+++ b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -63,7 +63,7 @@ router.delete("/:emoji", route({ permission: "MANAGE_MESSAGES" }), async (req: R
const message = await Message.findOneOrFail({ where: { id: message_id, channel_id } });
const already_added = message.reactions.find((x) => (x.emoji.id === emoji.id && emoji.id) || x.emoji.name === emoji.name);
- if (!already_added) throw new HTTPError("Reaction not found", 404);
+ if (!already_added) throw new HTTPError(req.t("common:notfound.REACTION"), 404);
message.reactions.remove(already_added);
await Promise.all([
@@ -89,7 +89,7 @@ router.get("/:emoji", route({ permission: "VIEW_CHANNEL" }), async (req: Request
const message = await Message.findOneOrFail({ where: { id: message_id, channel_id } });
const reaction = message.reactions.find((x) => (x.emoji.id === emoji.id && emoji.id) || x.emoji.name === emoji.name);
- if (!reaction) throw new HTTPError("Reaction not found", 404);
+ if (!reaction) throw new HTTPError(req.t("common:notfound.REACTION"), 404);
const users = await User.find({
where: {
@@ -163,7 +163,7 @@ router.delete("/:emoji/:user_id", route({}), async (req: Request, res: Response)
}
const already_added = message.reactions.find((x) => (x.emoji.id === emoji.id && emoji.id) || x.emoji.name === emoji.name);
- if (!already_added || !already_added.user_ids.includes(user_id)) throw new HTTPError("Reaction not found", 404);
+ if (!already_added || !already_added.user_ids.includes(user_id)) throw new HTTPError(req.t("common:notfound.REACTION"), 404);
already_added.count--;
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index 5fdcb6f9..220163d2 100644
--- a/src/api/routes/channels/#channel_id/messages/index.ts
+++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -53,7 +53,7 @@ export function isTextChannel(type: ChannelType): boolean {
router.get("/", async (req: Request, res: Response) => {
const channel_id = req.params.channel_id;
const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
- if (!channel) throw new HTTPError("Channel not found", 404);
+ if (!channel) throw new HTTPError(req.t("common:notfound.CHANNEL"), 404);
isTextChannel(channel.type);
const around = req.query.around ? `${req.query.around}` : undefined;
diff --git a/src/api/routes/channels/#channel_id/permissions.ts b/src/api/routes/channels/#channel_id/permissions.ts
index bd462ea6..6b888c80 100644
--- a/src/api/routes/channels/#channel_id/permissions.ts
+++ b/src/api/routes/channels/#channel_id/permissions.ts
@@ -21,12 +21,12 @@ router.put(
const body = req.body as ChannelPermissionOverwriteSchema;
let channel = await Channel.findOneOrFail({ where: { id: channel_id } });
- if (!channel.guild_id) throw new HTTPError("Channel not found", 404);
+ if (!channel.guild_id) throw new HTTPError(req.t("common:notfound.CHANNEL"), 404);
if (body.type === 0) {
- if (!(await Role.count({ where: { id: overwrite_id } }))) throw new HTTPError("role not found", 404);
+ if (!(await Role.count({ where: { id: overwrite_id } }))) throw new HTTPError(req.t("common:notfound.ROLE"), 404);
} else if (body.type === 1) {
- if (!(await Member.count({ where: { id: overwrite_id } }))) throw new HTTPError("user not found", 404);
+ if (!(await Member.count({ where: { id: overwrite_id } }))) throw new HTTPError(req.t("common:notfound.USER"), 404);
} else throw new HTTPError("type not supported", 501);
// @ts-ignore
@@ -60,7 +60,7 @@ router.delete("/:overwrite_id", route({ permission: "MANAGE_ROLES" }), async (re
const { channel_id, overwrite_id } = req.params;
const channel = await Channel.findOneOrFail({ where: { id: channel_id } });
- if (!channel.guild_id) throw new HTTPError("Channel not found", 404);
+ if (!channel.guild_id) throw new HTTPError(req.t("common:notfound.CHANNEL"), 404);
channel.permission_overwrites = channel.permission_overwrites!.filter((x) => x.id === overwrite_id);
diff --git a/src/api/routes/channels/#channel_id/webhooks.ts b/src/api/routes/channels/#channel_id/webhooks.ts
index 38dcb869..14e14c8b 100644
--- a/src/api/routes/channels/#channel_id/webhooks.ts
+++ b/src/api/routes/channels/#channel_id/webhooks.ts
@@ -23,7 +23,7 @@ router.post("/", route({ body: "WebhookCreateSchema", permission: "MANAGE_WEBHOO
let { avatar, name } = req.body as { name: string; avatar?: string };
name = trimSpecial(name);
- if (name === "clyde") throw new HTTPError("Invalid name", 400);
+ if (name.toLowerCase() === "clyde") throw new HTTPError("Invalid name", 400);
// TODO: save webhook in database and send response
res.json(new Webhook());
diff --git a/src/api/routes/guilds/#guild_id/stickers.ts b/src/api/routes/guilds/#guild_id/stickers.ts
index 15741780..06dade89 100644
--- a/src/api/routes/guilds/#guild_id/stickers.ts
+++ b/src/api/routes/guilds/#guild_id/stickers.ts
@@ -37,7 +37,7 @@ router.post(
bodyParser,
route({ permission: "MANAGE_EMOJIS_AND_STICKERS", body: "ModifyGuildStickerSchema" }),
async (req: Request, res: Response) => {
- if (!req.file) throw new HTTPError("missing file");
+ if (!req.file) throw new HTTPError(req.t("common:body.MISSING_FILE"));
const { guild_id } = req.params;
const body = req.body as ModifyGuildStickerSchema;
diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index 8267c142..e88aa714 100644
--- a/src/api/routes/users/@me/relationships.ts
+++ b/src/api/routes/users/@me/relationships.ts
@@ -69,7 +69,7 @@ router.post("/", route({ body: "RelationshipPostSchema" }), async (req: Request,
router.delete("/:id", route({}), async (req: Request, res: Response) => {
const { id } = req.params;
- if (id === req.user_id) throw new HTTPError("You can't remove yourself as a friend");
+ if (id === req.user_id) throw new HTTPError(req.t("common:relationship.REMOVE_SELF"));
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: userProjection, relations: ["relationships"] });
const friend = await User.findOneOrFail({ where: { id: id }, select: userProjection, relations: ["relationships"] });
@@ -77,7 +77,7 @@ router.delete("/:id", route({}), async (req: Request, res: Response) => {
const relationship = user.relationships.find((x) => x.to_id === id);
const friendRequest = friend.relationships.find((x) => x.to_id === req.user_id);
- if (!relationship) throw new HTTPError("You are not friends with the user", 404);
+ if (!relationship) throw new HTTPError(req.t("common:relationship.NOT_FRIENDS"));
if (relationship?.type === RelationshipType.blocked) {
// unblock user
@@ -118,7 +118,7 @@ export default router;
async function updateRelationship(req: Request, res: Response, friend: User, type: RelationshipType) {
const id = friend.id;
- if (id === req.user_id) throw new HTTPError("You can't add yourself as a friend");
+ if (id === req.user_id) throw new HTTPError(req.t("common:relationship.ADD_SELF"));
const user = await User.findOneOrFail({
where: { id: req.user_id },
@@ -132,7 +132,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
// TODO: you can add infinitely many blocked users (should this be prevented?)
if (type === RelationshipType.blocked) {
if (relationship) {
- if (relationship.type === RelationshipType.blocked) throw new HTTPError("You already blocked the user");
+ if (relationship.type === RelationshipType.blocked) throw new HTTPError(req.t("common:relationship.ALREADY_BLOCKED"));
relationship.type = RelationshipType.blocked;
await relationship.save();
} else {
@@ -178,17 +178,18 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
});
if (friendRequest) {
- if (friendRequest.type === RelationshipType.blocked) throw new HTTPError("The user blocked you");
- if (friendRequest.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
+ //TODO: shouldn't this be failed silently?
+ if (friendRequest.type === RelationshipType.blocked) throw new HTTPError(req.t("common:relationship.BLOCKED"));
+ if (friendRequest.type === RelationshipType.friends) throw new HTTPError(req.t("common:relationship.ALREADY_FRIENDS"));
// accept friend request
incoming_relationship = friendRequest as any; //TODO: checkme, any cast
incoming_relationship.type = RelationshipType.friends;
}
if (relationship) {
- if (relationship.type === RelationshipType.outgoing) throw new HTTPError("You already sent a friend request");
- if (relationship.type === RelationshipType.blocked) throw new HTTPError("Unblock the user before sending a friend request");
- if (relationship.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
+ if (relationship.type === RelationshipType.outgoing) throw new HTTPError(req.t("common:relationship.ALREADY_SENT"));
+ if (relationship.type === RelationshipType.blocked) throw new HTTPError(req.t("common:relationship.UNBLOCK"));
+ if (relationship.type === RelationshipType.friends) throw new HTTPError(req.t("common:relationship.ALREADY_FRIENDS"));
outgoing_relationship = relationship as any; //TODO: checkme, any cast
outgoing_relationship.type = RelationshipType.friends;
}
diff --git a/src/cdn/routes/attachments.ts b/src/cdn/routes/attachments.ts
index 013f03d8..bf74bd73 100644
--- a/src/cdn/routes/attachments.ts
+++ b/src/cdn/routes/attachments.ts
@@ -10,8 +10,8 @@ const router = Router();
const SANITIZED_CONTENT_TYPE = ["text/html", "text/mhtml", "multipart/related", "application/xhtml+xml"];
router.post("/:channel_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("file missing");
+ 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 { channel_id } = req.params;
@@ -49,7 +49,7 @@ router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) =>
const { channel_id, id, filename } = req.params;
const file = await storage.get(`attachments/${channel_id}/${id}/${filename}`);
- if (!file) throw new HTTPError("File not found");
+ if (!file) throw new HTTPError(req.t("common:notfound.FILE"));
const type = await FileType.fromBuffer(file);
let content_type = type?.mime || "application/octet-stream";
@@ -64,7 +64,7 @@ router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) =>
});
router.delete("/:channel_id/:id/:filename", 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 { channel_id, id, filename } = req.params;
const path = `attachments/${channel_id}/${id}/${filename}`;
diff --git a/src/cdn/routes/avatars.ts b/src/cdn/routes/avatars.ts
index fa26938f..1bd91942 100644
--- a/src/cdn/routes/avatars.ts
+++ b/src/cdn/routes/avatars.ts
@@ -17,8 +17,8 @@ const ALLOWED_MIME_TYPES = [...ANIMATED_MIME_TYPES, ...STATIC_MIME_TYPES];
const router = Router();
router.post("/:user_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 { user_id } = req.params;
@@ -47,7 +47,7 @@ router.get("/:user_id", async (req: Request, res: Response) => {
const path = `avatars/${user_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);
@@ -62,7 +62,7 @@ router.get("/:user_id/:hash", async (req: Request, res: Response) => {
const path = `avatars/${user_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);
@@ -72,7 +72,7 @@ router.get("/:user_id/:hash", async (req: Request, res: Response) => {
});
router.delete("/:user_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 { user_id, id } = req.params;
const path = `avatars/${user_id}/${id}`;
diff --git a/src/cdn/routes/external.ts b/src/cdn/routes/external.ts
index 7ccf9b8a..cd25268f 100644
--- a/src/cdn/routes/external.ts
+++ b/src/cdn/routes/external.ts
@@ -19,7 +19,7 @@ const DEFAULT_FETCH_OPTIONS: any = {
};
router.post("/", 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"));
if (!req.body) throw new HTTPError("Invalid Body");
@@ -44,7 +44,7 @@ router.get("/:id", async (req: Request, res: Response) => {
const { id } = req.params;
const file = await storage.get(`/external/${id}`);
- if (!file) throw new HTTPError("File not found");
+ if (!file) throw new HTTPError(req.t("common:notfound.FILE"));
const result = await FileType.fromBuffer(file);
res.set("Content-Type", result?.mime);
diff --git a/src/cdn/routes/guild-profiles.ts b/src/cdn/routes/guild-profiles.ts
index 32c05ad9..9fc3b80f 100644
--- a/src/cdn/routes/guild-profiles.ts
+++ b/src/cdn/routes/guild-profiles.ts
@@ -17,8 +17,8 @@ const ALLOWED_MIME_TYPES = [...ANIMATED_MIME_TYPES, ...STATIC_MIME_TYPES];
const router = Router();
router.post("/", 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 { guild_id, user_id } = req.params;
@@ -47,7 +47,7 @@ router.get("/", async (req: Request, res: Response) => {
const path = `guilds/${guild_id}/users/${user_id}/avatars`;
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);
@@ -62,7 +62,7 @@ router.get("/:hash", async (req: Request, res: Response) => {
const path = `guilds/${guild_id}/users/${user_id}/avatars/${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);
@@ -72,7 +72,7 @@ router.get("/:hash", async (req: Request, res: Response) => {
});
router.delete("/: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 { guild_id, user_id, id } = req.params;
const path = `guilds/${guild_id}/users/${user_id}/avatars/${id}`;
diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts
index 768e194f..4449f9d1 100644
--- a/src/cdn/routes/role-icons.ts
+++ b/src/cdn/routes/role-icons.ts
@@ -17,8 +17,8 @@ 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 +46,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 +61,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 +71,7 @@ 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}`;
|