mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 00:20:25 +00:00
Safer handling of incoming presence EDUs that may or maynot contain 'presence' or 'state'
This commit is contained in:
parent
7b56a7a3cb
commit
d9d6fbb085
1 changed files with 13 additions and 3 deletions
|
@ -655,10 +655,20 @@ class PresenceHandler(BaseHandler):
|
|||
state = dict(push)
|
||||
del state["user_id"]
|
||||
|
||||
# Legacy handling
|
||||
if "presence" not in state:
|
||||
if "presence" in state:
|
||||
# all is OK
|
||||
pass
|
||||
elif "state" in state:
|
||||
# Legacy handling
|
||||
state["presence"] = state["state"]
|
||||
del state["state"]
|
||||
else:
|
||||
logger.warning("Received a presence 'push' EDU from %s without"
|
||||
+ " either a 'presence' or 'state' key", origin
|
||||
)
|
||||
continue
|
||||
|
||||
if "state" in state:
|
||||
del state["state"]
|
||||
|
||||
if "last_active_ago" in state:
|
||||
state["last_active"] = int(
|
||||
|
|
Loading…
Reference in a new issue