mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
linting
This commit is contained in:
parent
a1de642fe7
commit
400bc061ca
@ -94,8 +94,12 @@ class ContentRepositoryConfig(Config):
|
|||||||
self.max_spider_size = self.parse_size(config.get("max_spider_size", "10M"))
|
self.max_spider_size = self.parse_size(config.get("max_spider_size", "10M"))
|
||||||
|
|
||||||
if self.enable_media_repo:
|
if self.enable_media_repo:
|
||||||
self.media_store_path = self.ensure_directory(config.get("media_store_path", "media_store"))
|
self.media_store_path = self.ensure_directory(
|
||||||
self.uploads_path = self.ensure_directory(config.get("uploads_path", "uploads"))
|
config.get("media_store_path", "media_store")
|
||||||
|
)
|
||||||
|
self.uploads_path = self.ensure_directory(
|
||||||
|
config.get("uploads_path", "uploads")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.media_store_path = None
|
self.media_store_path = None
|
||||||
self.uploads_path = None
|
self.uploads_path = None
|
||||||
|
@ -1011,8 +1011,7 @@ class FederationClient(FederationBase):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
complexity = yield self.transport_layer.get_room_complexity(
|
complexity = yield self.transport_layer.get_room_complexity(
|
||||||
destination=destination,
|
destination=destination, room_id=room_id
|
||||||
room_id=room_id
|
|
||||||
)
|
)
|
||||||
defer.returnValue(complexity)
|
defer.returnValue(complexity)
|
||||||
except CodeMessageException as e:
|
except CodeMessageException as e:
|
||||||
@ -1020,12 +1019,13 @@ class FederationClient(FederationBase):
|
|||||||
# servers don't give it to us.
|
# servers don't give it to us.
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Failed to fetch room complexity via %s for %s, got a %d",
|
"Failed to fetch room complexity via %s for %s, got a %d",
|
||||||
destination, room_id, e.code
|
destination,
|
||||||
|
room_id,
|
||||||
|
e.code,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Failed to fetch room complexity via %s for %s",
|
"Failed to fetch room complexity via %s for %s", destination, room_id
|
||||||
destination, room_id
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# If we don't manage to find it, return None. It's not an error if a
|
# If we don't manage to find it, return None. It's not an error if a
|
||||||
|
@ -945,14 +945,9 @@ class TransportLayerClient(object):
|
|||||||
destination (str): The remote server
|
destination (str): The remote server
|
||||||
room_id (str): The room ID to ask about.
|
room_id (str): The room ID to ask about.
|
||||||
"""
|
"""
|
||||||
path = _create_path(
|
path = _create_path(FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id)
|
||||||
FEDERATION_UNSTABLE_PREFIX, "/rooms/%s/complexity", room_id
|
|
||||||
)
|
|
||||||
|
|
||||||
return self.client.get_json(
|
return self.client.get_json(destination=destination, path=path)
|
||||||
destination=destination,
|
|
||||||
path=path
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _create_path(federation_prefix, path, *args):
|
def _create_path(federation_prefix, path, *args):
|
||||||
|
@ -1030,8 +1030,9 @@ class RoomMemberMasterHandler(RoomMemberHandler):
|
|||||||
)
|
)
|
||||||
if too_complex is True:
|
if too_complex is True:
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
code=400, msg=ROOM_COMPLEXITY_TOO_GREAT,
|
code=400,
|
||||||
errcode=Codes.RESOURCE_LIMIT_EXCEEDED
|
msg=ROOM_COMPLEXITY_TOO_GREAT,
|
||||||
|
errcode=Codes.RESOURCE_LIMIT_EXCEEDED,
|
||||||
)
|
)
|
||||||
|
|
||||||
# We don't do an auth check if we are doing an invite
|
# We don't do an auth check if we are doing an invite
|
||||||
@ -1058,18 +1059,14 @@ class RoomMemberMasterHandler(RoomMemberHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# The room is too large. Leave.
|
# The room is too large. Leave.
|
||||||
requester = types.create_requester(
|
requester = types.create_requester(user, None, False, None)
|
||||||
user, None, False, None
|
|
||||||
)
|
|
||||||
yield self.update_membership(
|
yield self.update_membership(
|
||||||
requester=requester,
|
requester=requester, target=user, room_id=room_id, action="leave"
|
||||||
target=user,
|
|
||||||
room_id=room_id,
|
|
||||||
action="leave"
|
|
||||||
)
|
)
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
code=400, msg=ROOM_COMPLEXITY_TOO_GREAT,
|
code=400,
|
||||||
errcode=Codes.RESOURCE_LIMIT_EXCEEDED
|
msg=ROOM_COMPLEXITY_TOO_GREAT,
|
||||||
|
errcode=Codes.RESOURCE_LIMIT_EXCEEDED,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -683,7 +683,9 @@ class EventsWorkerStore(SQLBaseStore):
|
|||||||
Deferred[int]
|
Deferred[int]
|
||||||
"""
|
"""
|
||||||
return self.runInteraction(
|
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):
|
def _get_current_state_event_counts_txn(self, txn, room_id):
|
||||||
|
@ -36,7 +36,7 @@ class RoomComplexityTests(unittest.HomeserverTestCase):
|
|||||||
login.register_servlets,
|
login.register_servlets,
|
||||||
]
|
]
|
||||||
|
|
||||||
def default_config(self, name='test'):
|
def default_config(self, name="test"):
|
||||||
config = super().default_config(name=name)
|
config = super().default_config(name=name)
|
||||||
config["limit_large_remote_room_joins"] = True
|
config["limit_large_remote_room_joins"] = True
|
||||||
config["limit_large_remote_room_complexity"] = 0.05
|
config["limit_large_remote_room_complexity"] = 0.05
|
||||||
|
Loading…
Reference in New Issue
Block a user