summary refs log tree commit diff
path: root/synapse/handlers/appservice.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-04-01 14:05:24 +0100
committerKegan Dougal <kegan@matrix.org>2015-04-01 14:05:24 +0100
commit813e54bd5b332e4514ecfea71d33d27f106fe5ff (patch)
treed31732038d54fda3f776f23b023b022b73850ca7 /synapse/handlers/appservice.py
parentMerge pull request #116 from matrix-org/application-services-registration-script (diff)
downloadsynapse-813e54bd5b332e4514ecfea71d33d27f106fe5ff.tar.xz
Fix more AS sender ID thinkos.
Specifically, the ASes own user ID wasn't being treated as 'exclusive' so
a human could nab it. Also, the HS would needlessly send user queries to the
AS for its own user ID.
Diffstat (limited to 'synapse/handlers/appservice.py')
-rw-r--r--synapse/handlers/appservice.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py
index 59cf15b037..492a630fdc 100644
--- a/synapse/handlers/appservice.py
+++ b/synapse/handlers/appservice.py
@@ -180,7 +180,14 @@ class ApplicationServicesHandler(object):
             return
 
         user_info = yield self.store.get_user_by_id(user_id)
-        defer.returnValue(len(user_info) == 0)
+        if len(user_info) > 0:
+            defer.returnValue(False)
+            return
+
+        # user not found; could be the AS though, so check.
+        services = yield self.store.get_app_services()
+        service_list = [s for s in services if s.sender == user_id]
+        defer.returnValue(len(service_list) == 0)
 
     @defer.inlineCallbacks
     def _check_user_exists(self, user_id):