Fix undiscovered linter errors (#17166)
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.
This commit is contained in:
parent
34a8652366
commit
393429d692
|
@ -0,0 +1 @@
|
||||||
|
Fixes linter errors found in PR #17147.
|
|
@ -20,7 +20,7 @@
|
||||||
#
|
#
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from typing import TYPE_CHECKING, Optional, Union
|
from typing import TYPE_CHECKING, List, Optional, Union
|
||||||
|
|
||||||
from synapse.api.errors import (
|
from synapse.api.errors import (
|
||||||
AuthError,
|
AuthError,
|
||||||
|
@ -64,8 +64,10 @@ class ProfileHandler:
|
||||||
self.user_directory_handler = hs.get_user_directory_handler()
|
self.user_directory_handler = hs.get_user_directory_handler()
|
||||||
self.request_ratelimiter = hs.get_request_ratelimiter()
|
self.request_ratelimiter = hs.get_request_ratelimiter()
|
||||||
|
|
||||||
self.max_avatar_size = hs.config.server.max_avatar_size
|
self.max_avatar_size: Optional[int] = hs.config.server.max_avatar_size
|
||||||
self.allowed_avatar_mimetypes = hs.config.server.allowed_avatar_mimetypes
|
self.allowed_avatar_mimetypes: Optional[List[str]] = (
|
||||||
|
hs.config.server.allowed_avatar_mimetypes
|
||||||
|
)
|
||||||
|
|
||||||
self._is_mine_server_name = hs.is_mine_server_name
|
self._is_mine_server_name = hs.is_mine_server_name
|
||||||
|
|
||||||
|
@ -337,6 +339,12 @@ class ProfileHandler:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.max_avatar_size:
|
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
|
# Ensure avatar does not exceed max allowed avatar size
|
||||||
if media_info.media_length > self.max_avatar_size:
|
if media_info.media_length > self.max_avatar_size:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|
Loading…
Reference in New Issue