diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-13 19:45:44 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-13 19:45:44 +1000 |
commit | 5a6cb33f5ead561cd2ac82afc7be6a00fc0707f7 (patch) | |
tree | e0a8a3b967a99b4a5c95c8b5a69a0b8a938c7a16 /src/api/routes/channels/#channel_id/messages | |
parent | scripts n shit (diff) | |
parent | fix style action (diff) | |
download | server-5a6cb33f5ead561cd2ac82afc7be6a00fc0707f7.tar.xz |
Merge branch 'master' into feat/refactorIdentify
Diffstat (limited to 'src/api/routes/channels/#channel_id/messages')
-rw-r--r-- | src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts | 14 | ||||
-rw-r--r-- | src/api/routes/channels/#channel_id/messages/index.ts | 6 |
2 files changed, 17 insertions, 3 deletions
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 eafa70c8..cb66cd64 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 @@ -28,6 +28,7 @@ import { MessageReactionRemoveEmojiEvent, MessageReactionRemoveEvent, PartialEmoji, + PublicMemberProjection, PublicUserProjection, User, } from "@spacebar/util"; @@ -180,6 +181,7 @@ router.put( if (already_added.user_ids.includes(req.user_id)) return res.sendStatus(204); // Do not throw an error ¯\_(ツ)_/¯ as discord also doesn't throw any error already_added.count++; + already_added.user_ids.push(req.user_id); } else message.reactions.push({ count: 1, @@ -191,7 +193,12 @@ router.put( const member = channel.guild_id && - (await Member.findOneOrFail({ where: { id: req.user_id } })); + ( + await Member.findOneOrFail({ + where: { id: req.user_id }, + select: PublicMemberProjection, + }) + ).toPublicMember(); await emitEvent({ event: "MESSAGE_REACTION_ADD", @@ -247,6 +254,11 @@ router.delete( already_added.count--; if (already_added.count <= 0) message.reactions.remove(already_added); + else + already_added.user_ids.splice( + already_added.user_ids.indexOf(user_id), + 1, + ); await message.save(); diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts index c871087a..7f0c9fb5 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts @@ -73,9 +73,11 @@ export function isTextChannel(type: ChannelType): boolean { // https://discord.com/developers/docs/resources/channel#create-message // get messages -router.get("/", async (req: Request, res: Response) => { +router.get("/", route({}), async (req: Request, res: Response) => { const channel_id = req.params.channel_id; - const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); + const channel = await Channel.findOneOrFail({ + where: { id: channel_id }, + }); if (!channel) throw new HTTPError("Channel not found", 404); isTextChannel(channel.type); |