Skip to content

Commit

Permalink
Fix undiscovered linter errors (#17166)
Browse files Browse the repository at this point in the history
Linter errors are showing up in #17147 that are unrelated to that PR.
The errors do not currently show up on develop.

This PR aims to resolve the linter errors separately from #17147.
  • Loading branch information
devonh authored May 8, 2024
1 parent 34a8652 commit 393429d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/17166.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes linter errors found in PR #17147.
14 changes: 11 additions & 3 deletions synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -337,6 +339,12 @@ async def check_avatar_size_and_mime_type(self, mxc: str) -> bool:
return False

if self.max_avatar_size:
if media_info.media_length is None:
logger.warning(
"Forbidding avatar change to %s: unknown media size",
mxc,
)
return False
# Ensure avatar does not exceed max allowed avatar size
if media_info.media_length > self.max_avatar_size:
logger.warning(
Expand Down

0 comments on commit 393429d

Please sign in to comment.