diff options
author | Daniel Wagner-Hall <daniel@matrix.org> | 2015-08-11 16:34:17 +0100 |
---|---|---|
committer | Daniel Wagner-Hall <daniel@matrix.org> | 2015-08-11 16:34:17 +0100 |
commit | 9dba813234fdeeef5097572dec9c975a4a83a99b (patch) | |
tree | d7aaaa231047881444f09993ec9b7e978d038c60 /synapse | |
parent | Use TypeError instead of ValueError and give a nicer error mesasge (diff) | |
download | synapse-9dba813234fdeeef5097572dec9c975a4a83a99b.tar.xz |
Remove redundant if-guard
The startswith("@") does the job
Diffstat (limited to '')
-rw-r--r-- | synapse/api/auth.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 487be7ce9c..bf02347f6a 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -521,23 +521,22 @@ class Auth(object): # Check state_key if hasattr(event, "state_key"): - if not event.state_key.startswith("_"): - if event.state_key.startswith("@"): - if event.state_key != event.user_id: + if event.state_key.startswith("@"): + if event.state_key != event.user_id: + raise AuthError( + 403, + "You are not allowed to set others state" + ) + else: + sender_domain = UserID.from_string( + event.user_id + ).domain + + if sender_domain != event.state_key: raise AuthError( 403, "You are not allowed to set others state" ) - else: - sender_domain = UserID.from_string( - event.user_id - ).domain - - if sender_domain != event.state_key: - raise AuthError( - 403, - "You are not allowed to set others state" - ) return True |