diff options
Diffstat (limited to 'src/api/routes/channels/#channel_id/recipients.ts')
-rw-r--r-- | src/api/routes/channels/#channel_id/recipients.ts | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/api/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts index 569bb5cd..c1377269 100644 --- a/src/api/routes/channels/#channel_id/recipients.ts +++ b/src/api/routes/channels/#channel_id/recipients.ts @@ -48,24 +48,16 @@ router.put( }); if (channel.type !== ChannelType.GROUP_DM) { - const recipients = [ - ...(channel.recipients?.map((r) => r.user_id) || []), - user_id, - ].unique(); + const recipients = [...(channel.recipients?.map((r) => r.user_id) || []), user_id].unique(); - const new_channel = await Channel.createDMChannel( - recipients, - req.user_id, - ); + const new_channel = await Channel.createDMChannel(recipients, req.user_id); 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? } - channel.recipients?.push( - Recipient.create({ channel_id: channel_id, user_id: user_id }), - ); + channel.recipients?.push(Recipient.create({ channel_id: channel_id, user_id: user_id })); await channel.save(); await emitEvent({ @@ -87,7 +79,7 @@ router.put( } as ChannelRecipientAddEvent); return res.sendStatus(204); } - }, + } ); router.delete( @@ -104,12 +96,7 @@ router.delete( where: { id: channel_id }, relations: ["recipients"], }); - if ( - !( - channel.type === ChannelType.GROUP_DM && - (channel.owner_id === req.user_id || user_id === req.user_id) - ) - ) + if (!(channel.type === ChannelType.GROUP_DM && (channel.owner_id === req.user_id || user_id === req.user_id))) throw DiscordApiErrors.MISSING_PERMISSIONS; if (!channel.recipients?.map((r) => r.user_id).includes(user_id)) { @@ -119,7 +106,7 @@ router.delete( await Channel.removeRecipientFromChannel(channel, user_id); return res.sendStatus(204); - }, + } ); export default router; |