mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-14 06:50:08 +00:00
Assert that requesting user is a member of (group/) DM before allowing them to add members
This commit is contained in:
@@ -39,6 +39,10 @@ router.put(
|
||||
relations: { recipients: true },
|
||||
});
|
||||
|
||||
if (!channel.recipients || channel.recipients.length == 0 || channel.recipients.filter((r) => r.user_id == req.user_id).length == 0) {
|
||||
throw DiscordApiErrors.UNKNOWN_CHANNEL; // TODO: is this the right error
|
||||
}
|
||||
|
||||
if (channel.type !== ChannelType.GROUP_DM) {
|
||||
const recipients = [...new Set([...(channel.recipients?.map((r) => r.user_id) || []), user_id])];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user