diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.py index 9d4eb77596..d7b9d565c4 100644 --- a/zerver/lib/upload/base.py +++ b/zerver/lib/upload/base.py @@ -1,4 +1,5 @@ import io +import os import re import unicodedata from typing import IO, Any, Callable, Optional, Tuple @@ -257,7 +258,7 @@ class ZulipUploadBackend: raise NotImplementedError() def realm_avatar_and_logo_path(self, realm: Realm) -> str: - raise NotImplementedError() + return os.path.join(str(realm.id), "realm") def create_attachment( diff --git a/zerver/lib/upload/local.py b/zerver/lib/upload/local.py index 0d2394e309..3ecbe85e11 100644 --- a/zerver/lib/upload/local.py +++ b/zerver/lib/upload/local.py @@ -175,9 +175,6 @@ class LocalUploadBackend(ZulipUploadBackend): image_data = read_local_file("avatars", source_file_path + ".original") 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: upload_path = self.realm_avatar_and_logo_path(user_profile.realm) image_data = icon_file.read() diff --git a/zerver/lib/upload/s3.py b/zerver/lib/upload/s3.py index 0070367002..f95b483bcb 100644 --- a/zerver/lib/upload/s3.py +++ b/zerver/lib/upload/s3.py @@ -312,9 +312,6 @@ class S3UploadBackend(ZulipUploadBackend): # export_path has a leading / 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: content_type = guess_type(icon_file.name)[0] s3_file_name = os.path.join(self.realm_avatar_and_logo_path(user_profile.realm), "icon")