1
0

store argument is no longer optional in is_interested_in_room

This commit is contained in:
Andrew Morgan
2021-12-10 15:42:03 +00:00
parent e1bc41b5c3
commit e580ca07b8
3 changed files with 11 additions and 11 deletions
+2 -5
View File
@@ -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
+1 -1
View File
@@ -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
+8 -5
View File
@@ -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)
)
)
)