gateway.websocket: merge default presence with given presence

should fix problems when presence does not have status field
This commit is contained in:
Luna 2018-12-06 00:58:35 -03:00
parent 5c3928069e
commit 1ba6fa5a3e
1 changed files with 10 additions and 11 deletions

View File

@ -398,8 +398,7 @@ class GatewayWebsocket:
# are just silently dropped. # are just silently dropped.
return return
if status is None: default_status = {
status = {
'afk': False, 'afk': False,
# TODO: fetch status from settings # TODO: fetch status from settings
@ -410,14 +409,14 @@ class GatewayWebsocket:
'since': 0, 'since': 0,
} }
self.state.presence = status
try: try:
status = validate(status, GW_STATUS_UPDATE) status = validate(status, GW_STATUS_UPDATE)
except BadRequest as err: except BadRequest as err:
log.warning(f'Invalid status update: {err}') log.warning(f'Invalid status update: {err}')
return return
status = {**status, **default_status}
# try to extract game from activities # try to extract game from activities
# when game not provided # when game not provided
if not status.get('game'): if not status.get('game'):