add validation for guild sync

This commit is contained in:
Luna 2021-07-03 00:00:47 -03:00
parent e01d1b8465
commit 173a2330fe
2 changed files with 12 additions and 0 deletions

View File

@ -99,6 +99,16 @@ REQ_GUILD_SCHEMA = {
},
}
GUILD_SYNC_SCHEMA = {
**BASE,
**{
"d": {
"type": "list",
"schema": {"type": "snowflake"},
}
},
}
GW_ACTIVITY = {
"name": {"type": "string", "required": True},

View File

@ -64,6 +64,7 @@ from litecord.gateway.schemas import (
GW_STATUS_UPDATE,
RESUME_SCHEMA,
REQ_GUILD_SCHEMA,
GUILD_SYNC_SCHEMA,
)
from litecord.storage import int_
@ -952,6 +953,7 @@ class GatewayWebsocket:
async def handle_12(self, payload: Dict[str, Any]):
"""Handle OP 12 Guild Sync."""
payload = validate(payload, GUILD_SYNC_SCHEMA)
data = payload["d"]
gids = await self.user_storage.get_user_guilds(self.state.user_id)