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

Commit

Permalink
Switch to using the ModuleApi in AccessRules
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Sep 11, 2020
1 parent 4e3163d commit 8aca853
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions synapse/third_party_rules/access_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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", []
Expand Down Expand Up @@ -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},
)
Expand Down Expand Up @@ -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, ""))
Expand Down

0 comments on commit 8aca853

Please sign in to comment.