uploads: Make realm_avatar_and_logo_path non-abstract.

This commit is contained in:
Alex Vandiver 2022-12-12 20:34:59 +00:00 committed by Alex Vandiver
parent 8e68d68f32
commit 43fe24a5a0
3 changed files with 2 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import io import io
import os
import re import re
import unicodedata import unicodedata
from typing import IO, Any, Callable, Optional, Tuple from typing import IO, Any, Callable, Optional, Tuple
@ -257,7 +258,7 @@ class ZulipUploadBackend:
raise NotImplementedError() raise NotImplementedError()
def realm_avatar_and_logo_path(self, realm: Realm) -> str: def realm_avatar_and_logo_path(self, realm: Realm) -> str:
raise NotImplementedError() return os.path.join(str(realm.id), "realm")
def create_attachment( def create_attachment(

View File

@ -175,9 +175,6 @@ class LocalUploadBackend(ZulipUploadBackend):
image_data = read_local_file("avatars", source_file_path + ".original") image_data = read_local_file("avatars", source_file_path + ".original")
self.write_avatar_images(target_file_path, image_data) self.write_avatar_images(target_file_path, image_data)
def realm_avatar_and_logo_path(self, realm: Realm) -> str:
return os.path.join(str(realm.id), "realm")
def upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None: def upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None:
upload_path = self.realm_avatar_and_logo_path(user_profile.realm) upload_path = self.realm_avatar_and_logo_path(user_profile.realm)
image_data = icon_file.read() image_data = icon_file.read()

View File

@ -312,9 +312,6 @@ class S3UploadBackend(ZulipUploadBackend):
# export_path has a leading / # export_path has a leading /
return self.get_public_upload_url(export_path[1:]) return self.get_public_upload_url(export_path[1:])
def realm_avatar_and_logo_path(self, realm: Realm) -> str:
return os.path.join(str(realm.id), "realm")
def upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None: def upload_realm_icon_image(self, icon_file: IO[bytes], user_profile: UserProfile) -> None:
content_type = guess_type(icon_file.name)[0] content_type = guess_type(icon_file.name)[0]
s3_file_name = os.path.join(self.realm_avatar_and_logo_path(user_profile.realm), "icon") s3_file_name = os.path.join(self.realm_avatar_and_logo_path(user_profile.realm), "icon")