From 28811da1b471e535442e2986687f16e206338d45 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 5 Dec 2018 22:56:39 -0300 Subject: [PATCH] schemas: add better handlers for GW_STATUS_UPDATE fields --- litecord/gateway/websocket.py | 2 +- litecord/schemas.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/litecord/gateway/websocket.py b/litecord/gateway/websocket.py index 6c83512..adf8795 100644 --- a/litecord/gateway/websocket.py +++ b/litecord/gateway/websocket.py @@ -415,7 +415,7 @@ class GatewayWebsocket: try: status = validate(status, GW_STATUS_UPDATE) except BadRequest as err: - log.warning(f'Invalid payload: {err}') + log.warning(f'Invalid status update: {err}') return # try to extract game from activities diff --git a/litecord/schemas.py b/litecord/schemas.py index 1240404..30a17a4 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -84,10 +84,6 @@ class LitecordValidator(Validator): def _validate_type_status_external(self, value: str) -> bool: statuses = StatusType.values() - - # clients should send INVISIBLE instead of OFFLINE - statuses.remove(StatusType.OFFLINE.value) - return value in statuses def _validate_type_explicit(self, value: str) -> bool: @@ -441,12 +437,13 @@ GW_ACTIVITY = { } GW_STATUS_UPDATE = { - 'status': {'type': 'status_external', 'required': False}, + 'status': {'type': 'status_external', 'required': False, + 'default': 'online'}, 'activities': { 'type': 'list', 'required': False, 'schema': GW_ACTIVITY}, 'afk': {'type': 'boolean', 'required': False}, - 'since': {'type': 'number', 'required': True, 'nullable': True}, + 'since': {'type': 'number', 'required': False, 'nullable': True}, 'game': { 'type': 'dict', 'required': False,