summary refs log tree commit diff
diff options
context:
space:
mode:
authorstefan080106 <stefan.arnold.programmierung@gmail.com>2021-04-26 21:16:29 +0200
committerstefan080106 <stefan.arnold.programmierung@gmail.com>2021-04-26 21:16:29 +0200
commit17e52f812cc63910de9895b20c6b52b998a708db (patch)
treedbb8df9ac272b656c3e6f0b609d6bcfae954fe9a
parentMerge pull request #86 from aryan0078/master (diff)
downloadserver-17e52f812cc63910de9895b20c6b52b998a708db.tar.xz
:lock: Fix parent id checking
-rw-r--r--src/routes/guilds/#guild_id/channels.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/routes/guilds/#guild_id/channels.ts b/src/routes/guilds/#guild_id/channels.ts

index d42ba481..19d466f3 100644 --- a/src/routes/guilds/#guild_id/channels.ts +++ b/src/routes/guilds/#guild_id/channels.ts
@@ -31,8 +31,9 @@ router.post("/", check(ChannelModifySchema), async (req, res) => { } if (body.parent_id) { - const exists = ChannelModel.findOne({ channel_id: body.parent_id }).exec(); + const exists = await ChannelModel.findOne({ id: body.parent_id }, {guild_id:true}).exec(); if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400); + if (exists.guild_id !== guild_id) throw new HTTPError("The category channel needs to be in the guild") } const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec();