diff options
Diffstat (limited to 'src/api/routes')
-rw-r--r-- | src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts | 14 |
1 files changed, 13 insertions, 1 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(); |