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,19 +398,16 @@ class GatewayWebsocket:
# are just silently dropped.
return
if status is None:
status = {
'afk': False,
default_status = {
'afk': False,
# TODO: fetch status from settings
'status': 'online',
'game': None,
# TODO: fetch status from settings
'status': 'online',
'game': None,
# TODO: this
'since': 0,
}
self.state.presence = status
# TODO: this
'since': 0,
}
try:
status = validate(status, GW_STATUS_UPDATE)
@ -418,6 +415,8 @@ class GatewayWebsocket:
log.warning(f'Invalid status update: {err}')
return
status = {**status, **default_status}
# try to extract game from activities
# when game not provided
if not status.get('game'):