1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-05 18:32:33 +01:00

send public member in message_reaction_add eventt

This commit is contained in:
Madeline 2023-04-11 13:47:26 +10:00
parent 88031fd0b7
commit ab07ad692c
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 20 additions and 2 deletions

View File

@ -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();

View File

@ -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 {