summary refs log tree commit diff
path: root/synapse/appservice
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-05 14:17:08 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-05 14:17:08 +0000
commitc71456117dc70dfe0bfa15e3f655a3ac1dfc66ee (patch)
treeff5edede759be25ea5e86545ac3cb8f369f7929f /synapse/appservice
parentSerialize events before sending to ASes (diff)
downloadsynapse-c71456117dc70dfe0bfa15e3f655a3ac1dfc66ee.tar.xz
Fix user query checks. HS>AS pushing now works.
Diffstat (limited to 'synapse/appservice')
-rw-r--r--synapse/appservice/__init__.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py
index d9ca856c8b..46d46a5a48 100644
--- a/synapse/appservice/__init__.py
+++ b/synapse/appservice/__init__.py
@@ -75,27 +75,23 @@ class ApplicationService(object):
 
     def _matches_user(self, event):
         if (hasattr(event, "sender") and
-                self._matches_regex(
-                event.sender, ApplicationService.NS_USERS)):
+                self.is_interested_in_user(event.sender)):
             return True
         # also check m.room.member state key
         if (hasattr(event, "type") and event.type == EventTypes.Member
                 and hasattr(event, "state_key")
-                and self._matches_regex(
-                event.state_key, ApplicationService.NS_USERS)):
+                and self.is_interested_in_user(event.state_key)):
             return True
         return False
 
     def _matches_room_id(self, event):
         if hasattr(event, "room_id"):
-            return self._matches_regex(
-                event.room_id, ApplicationService.NS_ROOMS
-            )
+            return self.is_interested_in_room(event.room_id)
         return False
 
     def _matches_aliases(self, event, alias_list):
         for alias in alias_list:
-            if self._matches_regex(alias, ApplicationService.NS_ALIASES):
+            if self.is_interested_in_alias(alias):
                 return True
         return False
 
@@ -128,5 +124,14 @@ class ApplicationService(object):
         elif restrict_to == ApplicationService.NS_USERS:
             return self._matches_user(event)
 
+    def is_interested_in_user(self, user_id):
+        return self._matches_regex(user_id, ApplicationService.NS_USERS)
+
+    def is_interested_in_alias(self, alias):
+        return self._matches_regex(alias, ApplicationService.NS_ALIASES)
+
+    def is_interested_in_room(self, room_id):
+        return self._matches_regex(room_id, ApplicationService.NS_ROOMS)
+
     def __str__(self):
         return "ApplicationService: %s" % (self.__dict__,)