summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-11 13:48:08 +1000
committerGitHub <noreply@github.com>2023-04-11 13:48:08 +1000
commit80c7eaa70f76b37b65698032ab5db8829260459d (patch)
tree6e0541eede810bb21f50a774ed68964bc25fdb95 /src/api
parentMerge pull request #1026 from ochen1/patch-3 (diff)
parentsend public member in message_reaction_add eventt (diff)
downloadserver-80c7eaa70f76b37b65698032ab5db8829260459d.tar.xz
Merge pull request #1023 from Rainb0wCodes/master
properly track reactions
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts14
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();