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:
parent
68d1b6efd2
commit
22952ef928
@ -7,6 +7,7 @@ import {
|
|||||||
MessageCreateEvent,
|
MessageCreateEvent,
|
||||||
MessageUpdateEvent,
|
MessageUpdateEvent,
|
||||||
getPermission,
|
getPermission,
|
||||||
|
getRights,
|
||||||
CHANNEL_MENTION,
|
CHANNEL_MENTION,
|
||||||
Snowflake,
|
Snowflake,
|
||||||
USER_MENTION,
|
USER_MENTION,
|
||||||
@ -61,17 +62,18 @@ 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 });
|
||||||
}
|
}
|
||||||
if (opts.webhook_id) {
|
if (opts.webhook_id) {
|
||||||
message.webhook = await Webhook.findOneOrFail({ id: opts.webhook_id });
|
message.webhook = await Webhook.findOneOrFail({ id: opts.webhook_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
const permission = await getPermission(opts.author_id, channel.guild_id, opts.channel_id);
|
const permission = await getPermission(opts.author_id, channel.guild_id, opts.channel_id);
|
||||||
permission.hasThrow("SEND_MESSAGES"); // TODO: add the rights check
|
permission.hasThrow("SEND_MESSAGES"); // TODO: add the rights check
|
||||||
if (permission.cache.member) {
|
if (permission.cache.member) {
|
||||||
|
Loading…
Reference in New Issue
Block a user