From a50d304aa33592e5c3df53fe8b78195fb38a34c0 Mon Sep 17 00:00:00 2001 From: Devon Hudson Date: Fri, 3 May 2024 15:02:33 -0600 Subject: [PATCH] Fix unrelated linter errors... --- synapse/handlers/profile.py | 13 +++++++++---- synapse/handlers/sso.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index e51e282a9f7..d66a6701ae0 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -20,7 +20,7 @@ # import logging import random -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, List, Optional, Union from synapse.api.errors import ( AuthError, @@ -64,8 +64,10 @@ def __init__(self, hs: "HomeServer"): self.user_directory_handler = hs.get_user_directory_handler() self.request_ratelimiter = hs.get_request_ratelimiter() - self.max_avatar_size = hs.config.server.max_avatar_size - self.allowed_avatar_mimetypes = hs.config.server.allowed_avatar_mimetypes + self.max_avatar_size: Optional[int] = hs.config.server.max_avatar_size + self.allowed_avatar_mimetypes: Optional[List[str]] = ( + hs.config.server.allowed_avatar_mimetypes + ) self._is_mine_server_name = hs.is_mine_server_name @@ -338,7 +340,10 @@ async def check_avatar_size_and_mime_type(self, mxc: str) -> bool: if self.max_avatar_size: # Ensure avatar does not exceed max allowed avatar size - if media_info.media_length > self.max_avatar_size: + if ( + media_info.media_length + and media_info.media_length > self.max_avatar_size + ): logger.warning( "Forbidding avatar change to %s: %d bytes is above the allowed size " "limit", diff --git a/synapse/handlers/sso.py b/synapse/handlers/sso.py index f275d4f35a1..ee74289b6c4 100644 --- a/synapse/handlers/sso.py +++ b/synapse/handlers/sso.py @@ -817,7 +817,7 @@ def is_allowed_mime_type(content_type: str) -> bool: server_name = profile["avatar_url"].split("/")[-2] media_id = profile["avatar_url"].split("/")[-1] if self._is_mine_server_name(server_name): - media = await self._media_repo.store.get_local_media(media_id) + media = await self._media_repo.store.get_local_media(media_id) # type: ignore[has-type] if media is not None and upload_name == media.upload_name: logger.info("skipping saving the user avatar") return True