summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-08 01:10:43 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-08 01:10:43 +0200
commit8e25f13796676285cdeba579e944f5b76fb77696 (patch)
treeafc3cbae6d43c07e3627c1a695c1a7d08516b318 /src/util
parent:bug: fix relationships (diff)
downloadserver-8e25f13796676285cdeba579e944f5b76fb77696.tar.xz
:bug: fix message permission check
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Message.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/Message.ts b/src/util/Message.ts

index 3e177517..e811f522 100644 --- a/src/util/Message.ts +++ b/src/util/Message.ts
@@ -25,10 +25,16 @@ const DEFAULT_FETCH_OPTIONS: any = { }; export async function handleMessage(opts: Partial<Message>) { - const channel = await ChannelModel.findOne({ id: opts.channel_id }, { guild_id: true, type: true, permission_overwrites: true }).exec(); + const channel = await ChannelModel.findOne( + { id: opts.channel_id }, + { guild_id: true, type: true, permission_overwrites: true, recipient_ids: true, owner_id: true } + ) + .lean() // lean is needed, because we don't want to populate .recipients that also auto deletes .recipient_ids + .exec(); if (!channel || !opts.channel_id) throw new HTTPError("Channel not found", 404); // TODO: are tts messages allowed in dm channels? should permission be checked? + // @ts-ignore const permissions = await getPermission(opts.author_id, channel.guild_id, opts.channel_id, { channel }); permissions.hasThrow("SEND_MESSAGES"); if (opts.tts) permissions.hasThrow("SEND_TTS_MESSAGES");