This commit is contained in:
Amber H. Brown 2019-07-05 22:44:22 +10:00
parent a1de642fe7
commit 400bc061ca
6 changed files with 25 additions and 27 deletions

View File

@ -94,8 +94,12 @@ class ContentRepositoryConfig(Config):
self.max_spider_size = self.parse_size(config.get("max_spider_size", "10M"))
if self.enable_media_repo:
self.media_store_path = self.ensure_directory(config.get("media_store_path", "media_store"))
self.uploads_path = self.ensure_directory(config.get("uploads_path", "uploads"))
self.media_store_path = self.ensure_directory(
config.get("media_store_path", "media_store")
)
self.uploads_path = self.ensure_directory(
config.get("uploads_path", "uploads")
)
else:
self.media_store_path = None
self.uploads_path = None

View File

@ -1011,8 +1011,7 @@ class FederationClient(FederationBase):
"""
try:
complexity = yield self.transport_layer.get_room_complexity(
destination=destination,
room_id=room_id
destination=destination, room_id=room_id
)
defer.returnValue(complexity)
except CodeMessageException as e:
@ -1020,12 +1019,13 @@ class FederationClient(FederationBase):
# servers don't give it to us.
logger.debug(
"Failed to fetch room complexity via %s for %s, got a %d",
destination, room_id, e.code
destination,
room_id,
e.code,
)
except Exception:
logger.exception(
"Failed to fetch room complexity via %s for %s",
destination, room_id
"Failed to fetch room complexity via %s for %s", destination, room_id
)
# If we don't manage to find it, return None. It's not an error if a

View File

@ -945,14 +945,9 @@ class TransportLayerClient(object):
destination (str): The remote server
room_id (str): The room ID to ask about.
"""
path = _create_path(
FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id
)
path = _create_path(FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id)
return self.client.get_json(
destination=destination,
path=path
)
return self.client.get_json(destination=destination, path=path)
def _create_path(federation_prefix, path, *args):

View File

@ -1030,8 +1030,9 @@ class RoomMemberMasterHandler(RoomMemberHandler):
)
if too_complex is True:
raise SynapseError(
code=400, msg=ROOM_COMPLEXITY_TOO_GREAT,
errcode=Codes.RESOURCE_LIMIT_EXCEEDED
code=400,
msg=ROOM_COMPLEXITY_TOO_GREAT,
errcode=Codes.RESOURCE_LIMIT_EXCEEDED,
)
# We don't do an auth check if we are doing an invite
@ -1058,18 +1059,14 @@ class RoomMemberMasterHandler(RoomMemberHandler):
return
# The room is too large. Leave.
requester = types.create_requester(
user, None, False, None
)
requester = types.create_requester(user, None, False, None)
yield self.update_membership(
requester=requester,
target=user,
room_id=room_id,
action="leave"
requester=requester, target=user, room_id=room_id, action="leave"
)
raise SynapseError(
code=400, msg=ROOM_COMPLEXITY_TOO_GREAT,
errcode=Codes.RESOURCE_LIMIT_EXCEEDED
code=400,
msg=ROOM_COMPLEXITY_TOO_GREAT,
errcode=Codes.RESOURCE_LIMIT_EXCEEDED,
)
@defer.inlineCallbacks

View File

@ -683,7 +683,9 @@ class EventsWorkerStore(SQLBaseStore):
Deferred[int]
"""
return self.runInteraction(
"get_current_state_event_counts", self._get_current_state_event_counts_txn, room_id
"get_current_state_event_counts",
self._get_current_state_event_counts_txn,
room_id,
)
def _get_current_state_event_counts_txn(self, txn, room_id):

View File

@ -36,7 +36,7 @@ class RoomComplexityTests(unittest.HomeserverTestCase):
login.register_servlets,
]
def default_config(self, name='test'):
def default_config(self, name="test"):
config = super().default_config(name=name)
config["limit_large_remote_room_joins"] = True
config["limit_large_remote_room_complexity"] = 0.05