enforce the rights

This commit is contained in:
Erkin Alp Güney 2022-04-08 11:02:11 +03:00 committed by GitHub
parent 627e06f783
commit 75e546cf72

View File

@ -7,6 +7,7 @@ import {
MessageCreateEvent, MessageCreateEvent,
MessageUpdateEvent, MessageUpdateEvent,
getPermission, getPermission,
getRights,
CHANNEL_MENTION, CHANNEL_MENTION,
Snowflake, Snowflake,
USER_MENTION, USER_MENTION,
@ -61,9 +62,10 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
throw new HTTPError("Content length over max character limit") throw new HTTPError("Content length over max character limit")
} }
// TODO: are tts messages allowed in dm channels? should permission be checked?
if (opts.author_id) { if (opts.author_id) {
message.author = await User.getPublicUser(opts.author_id); message.author = await User.getPublicUser(opts.author_id);
const rights = await getRights(opts.author_id);
rights.hasThrow("SEND_MESSAGES");
} }
if (opts.application_id) { if (opts.application_id) {
message.application = await Application.findOneOrFail({ id: opts.application_id }); message.application = await Application.findOneOrFail({ id: opts.application_id });