summary refs log tree commit diff
path: root/synapse/handlers/presence.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-02 11:17:43 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-02 11:17:43 +0100
commitd9d6fbb0856f87ee7d27ae1eb7d8bec9b21338cf (patch)
tree5f6bc42825d022435cb2ecf3a00de43a9f416983 /synapse/handlers/presence.py
parent'continue' to go to the next item in a for loop, not 'break' (diff)
downloadsynapse-d9d6fbb0856f87ee7d27ae1eb7d8bec9b21338cf.tar.xz
Safer handling of incoming presence EDUs that may or maynot contain 'presence' or 'state'
Diffstat (limited to '')
-rw-r--r--synapse/handlers/presence.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py

index b220970268..9bfceda88a 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py
@@ -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(