mirror of
https://github.com/element-hq/synapse
synced 2024-10-06 13:32:40 +00:00
Check presence state is a valid one
This commit is contained in:
parent
ddca9c56fc
commit
114b929f8b
2 changed files with 6 additions and 1 deletions
|
@ -32,7 +32,6 @@ class PresenceState(object):
|
||||||
OFFLINE = u"offline"
|
OFFLINE = u"offline"
|
||||||
UNAVAILABLE = u"unavailable"
|
UNAVAILABLE = u"unavailable"
|
||||||
ONLINE = u"online"
|
ONLINE = u"online"
|
||||||
FREE_FOR_CHAT = u"free_for_chat"
|
|
||||||
|
|
||||||
|
|
||||||
class JoinRules(object):
|
class JoinRules(object):
|
||||||
|
|
|
@ -606,6 +606,12 @@ class PresenceHandler(BaseHandler):
|
||||||
status_msg = state.get("status_msg", None)
|
status_msg = state.get("status_msg", None)
|
||||||
presence = state["presence"]
|
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()
|
user_id = target_user.to_string()
|
||||||
|
|
||||||
prev_state = yield self.current_state_for_user(user_id)
|
prev_state = yield self.current_state_for_user(user_id)
|
||||||
|
|
Loading…
Reference in a new issue