1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

enforce the rights

This commit is contained in:
Erkin Alp Güney 2022-04-08 11:02:11 +03:00 committed by GitHub
parent 68d1b6efd2
commit 22952ef928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import {
MessageCreateEvent,
MessageUpdateEvent,
getPermission,
getRights,
CHANNEL_MENTION,
Snowflake,
USER_MENTION,
@ -61,9 +62,10 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
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) {
message.author = await User.getPublicUser(opts.author_id);
const rights = await getRights(opts.author_id);
rights.hasThrow("SEND_MESSAGES");
}
if (opts.application_id) {
message.application = await Application.findOneOrFail({ id: opts.application_id });