channels: add bulk delete sql query

- schemas: add minlength, maxlength to BULK_DELETE
This commit is contained in:
Luna 2019-08-27 22:32:38 -03:00
parent 93237e34f8
commit e4386e8656
2 changed files with 8 additions and 2 deletions

View File

@ -688,14 +688,19 @@ async def bulk_delete(channel_id: int):
payload = {
'guild_id': str(guild_id),
'channel_id': str(channel_id),
'ids': message_ids
'ids': list(map(str, message_ids)),
}
# payload.guild_id is optional in the event, not nullable.
if guild_id is None:
payload.pop('guild_id')
# TODO delete messages
await app.db.execute("""
DELETE FROM messages
WHERE
channel_id = $1
AND ARRAY[message_id] <@ $2::bigint[]
""", channel_id, message_ids)
await app.dispatcher.dispatch_channel('MESSAGE_DELETE_BULK', payload)
return '', 204

View File

@ -741,6 +741,7 @@ WEBHOOK_MESSAGE_CREATE = {
BULK_DELETE = {
'messages': {
'type': 'list', 'required': True,
'minlength': 2, 'maxlength': 100,
'schema': {'coerce': int}
}
}