Safer handling of incoming presence EDUs that may or maynot contain 'presence' or 'state'

This commit is contained in:
Paul "LeoNerd" Evans 2014-09-02 11:17:43 +01:00
parent 7b56a7a3cb
commit d9d6fbb085

View File

@ -655,9 +655,19 @@ class PresenceHandler(BaseHandler):
state = dict(push) state = dict(push)
del state["user_id"] del state["user_id"]
if "presence" in state:
# all is OK
pass
elif "state" in state:
# Legacy handling # Legacy handling
if "presence" not in state:
state["presence"] = state["state"] state["presence"] = 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"] del state["state"]
if "last_active_ago" in state: if "last_active_ago" in state: