From 7d936efb2f37db42c3e57ee9a915ed4d5ab8e25f Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 27 Aug 2022 05:18:48 +0200 Subject: Cleanup, reformat, fix some todos, git hook fixup! Cleanup, reformat, fix some todos, git hook --- src/api/routes/channels/#channel_id/followers.ts | 2 +- .../#channel_id/messages/#message_id/crosspost.ts | 2 +- .../routes/channels/#channel_id/messages/index.ts | 27 +++++++++++++--------- src/api/routes/channels/#channel_id/recipients.ts | 4 ++-- 4 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/api/routes/channels') diff --git a/src/api/routes/channels/#channel_id/followers.ts b/src/api/routes/channels/#channel_id/followers.ts index c06db61b..d91f4b84 100644 --- a/src/api/routes/channels/#channel_id/followers.ts +++ b/src/api/routes/channels/#channel_id/followers.ts @@ -1,6 +1,6 @@ import { Router } from "express"; const router: Router = Router(); -// TODO: +// TODO: implement route export default router; diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts index fbbc65f0..5cdb2ba1 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts @@ -4,7 +4,7 @@ import { Request, Response, Router } from "express"; const router = Router(); router.post("/", route({ permission: "MANAGE_MESSAGES" }), (req: Request, res: Response) => { - // TODO: + // TODO: implement route res.json({ id: "", type: 0, diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index d542ea0f..00008ed4 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -12,12 +12,10 @@ import { Message, MessageCreateEvent, MessageCreateSchema, - Snowflake, - uploadFile, - Member, - MessageCreateSchema, PluginEventHandler, - PreMessageEventArgs + PreMessageEventArgs, + Snowflake, + uploadFile } from "@fosscord/util"; import { Request, Response, Router } from "express"; import multer from "multer"; @@ -210,8 +208,8 @@ router.post( }) ); } - - //Defining member fields + + //Defining member fields var member = await Member.findOneOrFail({ where: { id: req.user_id }, relations: ["roles", "user"] }); // TODO: This doesn't work either // member.roles = member.roles.filter((role) => { @@ -224,10 +222,17 @@ router.post( // delete message.member.last_message_id; // delete message.member.index; - let blocks = (await PluginEventHandler.preMessageEvent({ - message - } as PreMessageEventArgs)).filter(x=>x.cancel); - if(blocks.length > 0) throw new HTTPError("Message denied.", 400, blocks.filter(x=>x.blockReason).map(x=>x.blockReason)); + let blocks = ( + await PluginEventHandler.preMessageEvent({ + message + } as PreMessageEventArgs) + ).filter((x) => x.cancel); + if (blocks.length > 0) + throw new HTTPError( + "Message denied.", + 400, + blocks.filter((x) => x.blockReason).map((x) => x.blockReason) + ); await Promise.all([ message.save(), diff --git a/src/api/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts index 276a0eda..fc6b6b4f 100644 --- a/src/api/routes/channels/#channel_id/recipients.ts +++ b/src/api/routes/channels/#channel_id/recipients.ts @@ -26,7 +26,7 @@ router.put("/:user_id", route({}), async (req: Request, res: Response) => { return res.status(201).json(new_channel); } else { if (channel.recipients!.map((r) => r.user_id).includes(user_id)) { - throw DiscordApiErrors.INVALID_RECIPIENT; //TODO is this the right error? + throw DiscordApiErrors.INVALID_RECIPIENT; //TODO: is this the right error? } channel.recipients!.push(OrmUtils.mergeDeep(new Recipient(), { channel_id, user_id: user_id })); @@ -57,7 +57,7 @@ router.delete("/:user_id", route({}), async (req: Request, res: Response) => { throw DiscordApiErrors.MISSING_PERMISSIONS; if (!channel.recipients!.map((r) => r.user_id).includes(user_id)) { - throw DiscordApiErrors.INVALID_RECIPIENT; //TODO is this the right error? + throw DiscordApiErrors.INVALID_RECIPIENT; //TODO: is this the right error? } await Channel.removeRecipientFromChannel(channel, user_id); -- cgit 1.4.1