summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-11 13:47:26 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-11 13:47:26 +1000
commitab07ad692c837e5abe016cfb4a973d35d50c8d44 (patch)
tree2bbe8ab1417f9f00be03fc2baa53491424393f27
parentUpdate reactions.ts (diff)
downloadserver-ab07ad692c837e5abe016cfb4a973d35d50c8d44.tar.xz
send public member in message_reaction_add eventt
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts13
-rw-r--r--src/util/entities/Member.ts9
2 files changed, 20 insertions, 2 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 e0a51668..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";
@@ -192,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",
@@ -249,7 +255,10 @@ router.delete(
 
 		if (already_added.count <= 0) message.reactions.remove(already_added);
 		else
-			already_added.user_ids.splice(already_added.user_ids.indexOf(user_id), 1);
+			already_added.user_ids.splice(
+				already_added.user_ids.indexOf(user_id),
+				1,
+			);
 
 		await message.save();
 
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 13e74dcd..cd885c13 100644
--- a/src/util/entities/Member.ts
+++ b/src/util/entities/Member.ts
@@ -440,6 +440,15 @@ export class Member extends BaseClassWithoutId {
 			]);
 		}
 	}
+
+	toPublicMember() {
+		// eslint-disable-next-line @typescript-eslint/no-explicit-any
+		const member: any = {};
+		PublicMemberProjection.forEach((x) => {
+			member[x] = this[x];
+		});
+		return member as PublicMember;
+	}
 }
 
 export interface ChannelOverride {