diff options
author | reivilibre <oliverw@matrix.org> | 2022-09-14 15:53:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-14 15:53:18 +0000 |
commit | 6302753012927b63feddc71dd287e2d3554707d4 (patch) | |
tree | f6ef20890b30492f604a3ac2e4e9d7b8daa87a9b /synapse/storage/databases/main/roommember.py | |
parent | Fix a memory leak when running the unit tests. (#13798) (diff) | |
download | synapse-6302753012927b63feddc71dd287e2d3554707d4.tar.xz |
Deduplicate `is_server_notices_room`. (#13780)
Diffstat (limited to 'synapse/storage/databases/main/roommember.py')
-rw-r--r-- | synapse/storage/databases/main/roommember.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index fdb4684e12..a8d224602a 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -88,6 +88,8 @@ class RoomMemberWorkerStore(EventsWorkerStore): # at a time. Keyed by room_id. self._joined_host_linearizer = Linearizer("_JoinedHostsCache") + self._server_notices_mxid = hs.config.servernotices.server_notices_mxid + if ( self.hs.config.worker.run_background_tasks and self.hs.config.metrics.metrics_flags.known_servers @@ -504,6 +506,21 @@ class RoomMemberWorkerStore(EventsWorkerStore): return membership == Membership.JOIN + async def is_server_notice_room(self, room_id: str) -> bool: + """ + Determines whether the given room is a 'Server Notices' room, used for + sending server notices to a user. + + This is determined by seeing whether the server notices user is present + in the room. + """ + if self._server_notices_mxid is None: + return False + is_server_notices_room = await self.check_local_user_in_room( + user_id=self._server_notices_mxid, room_id=room_id + ) + return is_server_notices_room + async def get_local_current_membership_for_user_in_room( self, user_id: str, room_id: str ) -> Tuple[Optional[str], Optional[str]]: |