Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
store argument is no longer optional in is_interested_in_room
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 1, 2022
1 parent 60a291a commit 7e6d343
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
7 changes: 2 additions & 5 deletions synapse/appservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ async def is_interested_in_room(
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.
Expand Down Expand Up @@ -288,10 +288,7 @@ async def is_interested_in_event(
):
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
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ async def _get_services_for_event(
# 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
Expand Down
13 changes: 8 additions & 5 deletions tests/appservice/test_appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from synapse.appservice import ApplicationService, Namespace

from tests import unittest
from tests.test_utils import simple_async_mock


def _regex(regex: str, exclusive: bool = True) -> Namespace:
Expand All @@ -39,6 +40,8 @@ def setUp(self):
)

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):
Expand All @@ -47,7 +50,7 @@ def test_regex_user_id_prefix_match(self):
self.assertTrue(
(
yield defer.ensureDeferred(
self.service.is_interested_in_event(self.event)
self.service.is_interested_in_event(self.event, self.store)
)
)
)
Expand All @@ -59,7 +62,7 @@ def test_regex_user_id_prefix_no_match(self):
self.assertFalse(
(
yield defer.ensureDeferred(
self.service.is_interested_in_event(self.event)
self.service.is_interested_in_event(self.event, self.store)
)
)
)
Expand All @@ -73,7 +76,7 @@ def test_regex_room_member_is_checked(self):
self.assertTrue(
(
yield defer.ensureDeferred(
self.service.is_interested_in_event(self.event)
self.service.is_interested_in_event(self.event, self.store)
)
)
)
Expand Down Expand Up @@ -102,7 +105,7 @@ def test_regex_room_id_no_match(self):
self.assertFalse(
(
yield defer.ensureDeferred(
self.service.is_interested_in_event(self.event)
self.service.is_interested_in_event(self.event, self.store)
)
)
)
Expand Down Expand Up @@ -207,7 +210,7 @@ def test_interested_in_self(self):
self.assertTrue(
(
yield defer.ensureDeferred(
self.service.is_interested_in_event(self.event)
self.service.is_interested_in_event(self.event, self.store)
)
)
)
Expand Down

0 comments on commit 7e6d343

Please sign in to comment.