mirror of https://gitlab.com/litecord/litecord.git
channels: add bulk delete sql query
- schemas: add minlength, maxlength to BULK_DELETE
This commit is contained in:
parent
93237e34f8
commit
e4386e8656
|
|
@ -688,14 +688,19 @@ async def bulk_delete(channel_id: int):
|
||||||
payload = {
|
payload = {
|
||||||
'guild_id': str(guild_id),
|
'guild_id': str(guild_id),
|
||||||
'channel_id': str(channel_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.
|
# payload.guild_id is optional in the event, not nullable.
|
||||||
if guild_id is None:
|
if guild_id is None:
|
||||||
payload.pop('guild_id')
|
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)
|
await app.dispatcher.dispatch_channel('MESSAGE_DELETE_BULK', payload)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
|
||||||
|
|
@ -741,6 +741,7 @@ WEBHOOK_MESSAGE_CREATE = {
|
||||||
BULK_DELETE = {
|
BULK_DELETE = {
|
||||||
'messages': {
|
'messages': {
|
||||||
'type': 'list', 'required': True,
|
'type': 'list', 'required': True,
|
||||||
|
'minlength': 2, 'maxlength': 100,
|
||||||
'schema': {'coerce': int}
|
'schema': {'coerce': int}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue