Assert that requesting user is a member of (group/) DM before allowing them to add members

This commit is contained in:
Rory&
2026-08-04 13:28:48 +02:00
parent 51da17cf19
commit dcfd91035e
@@ -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])];