summary refs log tree commit diff
path: root/synapse/appservice
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-03-28 13:25:18 +0100
committerErik Johnston <erik@matrix.org>2017-03-28 13:27:21 +0100
commit51b156d48a14f1f3c8b03a6901317b0330cd368b (patch)
tree6cf9917d9b7e929bbda1b596564ce12ced3a3e97 /synapse/appservice
parentRemove param and cast at call site (diff)
downloadsynapse-51b156d48a14f1f3c8b03a6901317b0330cd368b.tar.xz
Cache whether an AS is interested based on members
Diffstat (limited to 'synapse/appservice')
-rw-r--r--synapse/appservice/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py
index 885d14fa91..48791f0d9b 100644
--- a/synapse/appservice/__init__.py
+++ b/synapse/appservice/__init__.py
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 from synapse.api.constants import EventTypes
+from synapse.util.caches.descriptors import cachedInlineCallbacks
 
 from twisted.internet import defer
 
@@ -160,7 +161,14 @@ class ApplicationService(object):
         if not store:
             defer.returnValue(False)
 
-        member_list = yield store.get_users_in_room(event.room_id)
+        does_match = yield self._matches_user_in_member_list(event.room_id, store)
+        defer.returnValue(does_match)
+
+    @cachedInlineCallbacks(num_args=1, cache_context=True)
+    def _matches_user_in_member_list(self, room_id, store, cache_context):
+        member_list = yield store.get_users_in_room(
+            room_id, on_invalidate=cache_context.invalidate
+        )
 
         # check joined member events
         for user_id in member_list: