From 8aca853c222c41516d0851388a608bcf636f8e69 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 11 Sep 2020 17:35:41 +0100 Subject: [PATCH] Switch to using the ModuleApi in AccessRules --- synapse/third_party_rules/access_rules.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/synapse/third_party_rules/access_rules.py b/synapse/third_party_rules/access_rules.py index 132c183c98..abac818d7b 100644 --- a/synapse/third_party_rules/access_rules.py +++ b/synapse/third_party_rules/access_rules.py @@ -21,8 +21,7 @@ from synapse.api.errors import SynapseError from synapse.config._base import ConfigError from synapse.events import EventBase -from synapse.events.third_party_rules import PublicRoomsManager -from synapse.http.client import SimpleHttpClient +from synapse.module_api import ModuleApi from synapse.types import Requester, StateMap, get_domain_from_id ACCESS_RULES_TYPE = "im.vector.room.access_rules" @@ -76,17 +75,10 @@ class RoomAccessRules(object): """ def __init__( - self, - config: Dict, - http_client: SimpleHttpClient, - public_room_manager: PublicRoomsManager, - *args, - **kwargs, + self, config: Dict, module_api: ModuleApi, ): - self.http_client = http_client - self.public_room_manager = public_room_manager - self.id_server = config["id_server"] + self.module_api = module_api self.domains_forbidden_when_restricted = config.get( "domains_forbidden_when_restricted", [] @@ -285,7 +277,7 @@ def check_threepid_can_be_invited( return False # Get the HS this address belongs to from the identity server. - res = yield self.http_client.get_json( + res = yield self.module_api.http_client.get_json( "https://%s/_matrix/identity/api/v1/info" % (self.id_server,), {"medium": medium, "address": address}, ) @@ -399,9 +391,7 @@ async def _on_rules_change( if new_rule == AccessRules.UNRESTRICTED: # Block this change if this room is currently listed in the public rooms # directory - if await self.public_room_manager.room_is_in_public_directory( - event.room_id - ): + if await self.module_api.room_is_in_public_directory(event.room_id): return False prev_rules_event = state_events.get((ACCESS_RULES_TYPE, ""))