Backfilling privilege does not imply right to post messages

This commit is contained in:
Erkin Alp Güney 2022-04-24 09:23:52 +03:00 committed by GitHub
parent 2e84840213
commit 122abacf17

View File

@ -93,9 +93,12 @@ router.put(
var body = req.body as MessageCreateSchema; var body = req.body as MessageCreateSchema;
const attachments: Attachment[] = []; const attachments: Attachment[] = [];
const rights = getRights(req.user_id);
rights.hasThrow("SEND_MESSAGES");
// regex to check if message contains anything other than numerals ( also no decimals ) // regex to check if message contains anything other than numerals ( also no decimals )
if (!message_id.match(/^\+?\d+$/)) { if (!message_id.match(/^\+?\d+$/)) {
throw new HTTPError("Message IDs must be positive integers") throw new HTTPError("Message IDs must be positive integers", 400);
} }
const snowflake = Snowflake.deconstruct(message_id) const snowflake = Snowflake.deconstruct(message_id)
@ -106,7 +109,7 @@ router.put(
const exists = await Message.findOne({ where: { id: message_id, channel_id: channel_id }}); const exists = await Message.findOne({ where: { id: message_id, channel_id: channel_id }});
if (exists) { if (exists) {
throw new HTTPError("Cannot backfill to message ID that already exists", 400); throw new HTTPError("Cannot backfill to message ID that already exists", 409);
} }
if (req.file) { if (req.file) {