summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-18 09:16:32 +0000
committerErik Johnston <erik@matrix.org>2016-02-18 09:16:32 +0000
commit114b929f8bdd3dcc165fd488c087aaca3dc8bd91 (patch)
treefde322343416564f6818d77143462e31336d02ba
parentMove if statement (diff)
downloadsynapse-114b929f8bdd3dcc165fd488c087aaca3dc8bd91.tar.xz
Check presence state is a valid one
Diffstat (limited to '')
-rw-r--r--synapse/api/constants.py1
-rw-r--r--synapse/handlers/presence.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/synapse/api/constants.py b/synapse/api/constants.py
index 84cbe710b3..8cf4d6169c 100644
--- a/synapse/api/constants.py
+++ b/synapse/api/constants.py
@@ -32,7 +32,6 @@ class PresenceState(object):
     OFFLINE = u"offline"
     UNAVAILABLE = u"unavailable"
     ONLINE = u"online"
-    FREE_FOR_CHAT = u"free_for_chat"
 
 
 class JoinRules(object):
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 1942e2ad30..439bfe5919 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -606,6 +606,12 @@ class PresenceHandler(BaseHandler):
         status_msg = state.get("status_msg", None)
         presence = state["presence"]
 
+        valid_presence = (
+            PresenceState.ONLINE, PresenceState.UNAVAILABLE, PresenceState.OFFLINE
+        )
+        if presence not in valid_presence:
+            raise SynapseError(400, "Invalid presence state")
+
         user_id = target_user.to_string()
 
         prev_state = yield self.current_state_for_user(user_id)