mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
settings: Rename MAX_AVATAR_FILE_SIZE.
Rename MAX_AVATAR_FILE_SIZE to MAX_AVATAR_FILE_SIZE_MIB reflecting size in mebibytes.
This commit is contained in:
committed by
Tim Abbott
parent
66f77d3b4b
commit
0f6bb210a6
@@ -241,7 +241,7 @@ def fetch_initial_state_data(
|
||||
state["realm_presence_disabled"] = True if user_profile is None else realm.presence_disabled
|
||||
|
||||
# Important: Encode units in the client-facing API name.
|
||||
state["max_avatar_file_size_mib"] = settings.MAX_AVATAR_FILE_SIZE
|
||||
state["max_avatar_file_size_mib"] = settings.MAX_AVATAR_FILE_SIZE_MIB
|
||||
state["max_file_upload_size_mib"] = settings.MAX_FILE_UPLOAD_SIZE
|
||||
state["max_icon_file_size_mib"] = settings.MAX_ICON_FILE_SIZE
|
||||
state["realm_upload_quota_mib"] = realm.upload_quota_bytes()
|
||||
|
||||
@@ -1238,7 +1238,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
|
||||
def test_avatar_upload_file_size_error(self) -> None:
|
||||
self.login("hamlet")
|
||||
with get_test_image_file(self.correct_files[0][0]) as fp:
|
||||
with self.settings(MAX_AVATAR_FILE_SIZE=0):
|
||||
with self.settings(MAX_AVATAR_FILE_SIZE_MIB=0):
|
||||
result = self.client_post("/json/users/me/avatar", {"file": fp})
|
||||
self.assert_json_error(result, "Uploaded file is larger than the allowed limit of 0 MiB")
|
||||
|
||||
|
||||
@@ -297,10 +297,10 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
|
||||
return json_error(str(AVATAR_CHANGES_DISABLED_ERROR))
|
||||
|
||||
user_file = list(request.FILES.values())[0]
|
||||
if (settings.MAX_AVATAR_FILE_SIZE * 1024 * 1024) < user_file.size:
|
||||
if (settings.MAX_AVATAR_FILE_SIZE_MIB * 1024 * 1024) < user_file.size:
|
||||
return json_error(
|
||||
_("Uploaded file is larger than the allowed limit of {} MiB").format(
|
||||
settings.MAX_AVATAR_FILE_SIZE,
|
||||
settings.MAX_AVATAR_FILE_SIZE_MIB,
|
||||
)
|
||||
)
|
||||
upload_avatar_image(user_file, user_profile, user_profile)
|
||||
|
||||
@@ -307,7 +307,7 @@ ZULIP_IOS_APP_ID = "org.zulip.Zulip"
|
||||
|
||||
# Limits related to the size of file uploads; last few in MB.
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 25 * 1024 * 1024
|
||||
MAX_AVATAR_FILE_SIZE = 5
|
||||
MAX_AVATAR_FILE_SIZE_MIB = 5
|
||||
MAX_ICON_FILE_SIZE = 5
|
||||
MAX_LOGO_FILE_SIZE = 5
|
||||
MAX_EMOJI_FILE_SIZE = 5
|
||||
|
||||
Reference in New Issue
Block a user