summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-12-10 15:42:03 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2021-12-10 15:50:51 +0000
commite580ca07b85498bfc4d10054d39ebd0a869aa23b (patch)
treef9cc2053e8bf24cfd2c0d8aa4f1ff0dd3a58e1d3
parentSquash into and use everywhere (diff)
downloadsynapse-e580ca07b85498bfc4d10054d39ebd0a869aa23b.tar.xz
store argument is no longer optional in is_interested_in_room
-rw-r--r--synapse/appservice/__init__.py7
-rw-r--r--synapse/handlers/appservice.py2
-rw-r--r--tests/appservice/test_appservice.py13
3 files changed, 11 insertions, 11 deletions
diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py
index 247d84ad5c..01db2b2ae3 100644
--- a/synapse/appservice/__init__.py
+++ b/synapse/appservice/__init__.py
@@ -238,8 +238,8 @@ class ApplicationService:
     async def is_interested_in_event(
         self,
         event: EventBase,
+        store: "DataStore",
         cache_context: _CacheContext,
-        store: Optional["DataStore"] = None,
     ) -> bool:
         """Check if this service is interested in this event.
 
@@ -267,10 +267,7 @@ class ApplicationService:
         ):
             return True
 
-        # TODO: The store is only optional here to aid testing this function. We should
-        #  instead convert the tests to use HomeServerTestCase in order to get a working
-        #  database instance.
-        if store is not None and await self.is_interested_in_room(
+        if await self.is_interested_in_room(
             event.room_id, store, on_invalidate=cache_context.invalidate
         ):
             return True
diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py
index 3dc0d89530..fb533188a2 100644
--- a/synapse/handlers/appservice.py
+++ b/synapse/handlers/appservice.py
@@ -768,7 +768,7 @@ class ApplicationServicesHandler:
         # inside of a list comprehension anymore.
         interested_list = []
         for s in services:
-            if await s.is_interested_in_event(event, store=self.store):
+            if await s.is_interested_in_event(event, self.store):
                 interested_list.append(s)
 
         return interested_list
diff --git a/tests/appservice/test_appservice.py b/tests/appservice/test_appservice.py
index b7ab97173f..9dd4f26b35 100644
--- a/tests/appservice/test_appservice.py
+++ b/tests/appservice/test_appservice.py
@@ -19,6 +19,7 @@ from twisted.internet import defer
 from synapse.appservice import ApplicationService
 
 from tests import unittest
+from tests.test_utils import simple_async_mock
 
 
 def _regex(regex, exclusive=True):
@@ -44,6 +45,8 @@ class ApplicationServiceTestCase(unittest.TestCase):
         )
 
         self.store = Mock()
+        self.store.get_aliases_for_room = simple_async_mock(return_value=[])
+        self.store.get_users_in_room = simple_async_mock(return_value=[])
 
     @defer.inlineCallbacks
     def test_regex_user_id_prefix_match(self):
@@ -52,7 +55,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
         self.assertTrue(
             (
                 yield defer.ensureDeferred(
-                    self.service.is_interested_in_event(self.event)
+                    self.service.is_interested_in_event(self.event, self.store)
                 )
             )
         )
@@ -64,7 +67,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
         self.assertFalse(
             (
                 yield defer.ensureDeferred(
-                    self.service.is_interested_in_event(self.event)
+                    self.service.is_interested_in_event(self.event, self.store)
                 )
             )
         )
@@ -78,7 +81,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
         self.assertTrue(
             (
                 yield defer.ensureDeferred(
-                    self.service.is_interested_in_event(self.event)
+                    self.service.is_interested_in_event(self.event, self.store)
                 )
             )
         )
@@ -107,7 +110,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
         self.assertFalse(
             (
                 yield defer.ensureDeferred(
-                    self.service.is_interested_in_event(self.event)
+                    self.service.is_interested_in_event(self.event, self.store)
                 )
             )
         )
@@ -212,7 +215,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
         self.assertTrue(
             (
                 yield defer.ensureDeferred(
-                    self.service.is_interested_in_event(self.event)
+                    self.service.is_interested_in_event(self.event, self.store)
                 )
             )
         )