Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

avatars: Use a helper method, rather than use upload_backend directly.

Alex Vandiver862e3bb80a58
diff --git a/zerver/lib/avatar.py b/zerver/lib/avatar.py
index 0371bba19d8..506a0bd3401 100644
--- a/zerver/lib/avatar.py
+++ b/zerver/lib/avatar.py
@@ -8,7 +8,7 @@ from zerver.lib.avatar_hash import (
user_avatar_content_hash,
user_avatar_path_from_ids,
)
-from zerver.lib.upload import upload_backend
+from zerver.lib.upload import get_avatar_url
from zerver.lib.upload.base import MEDIUM_AVATAR_SIZE
from zerver.lib.url_encoding import append_url_query_string
from zerver.models import UserProfile
@@ -120,7 +120,7 @@ def _get_unversioned_avatar_url(
) -> str:
if avatar_source == "U":
hash_key = user_avatar_path_from_ids(user_profile_id, realm_id)
- return upload_backend.get_avatar_url(hash_key, medium=medium)
+ return get_avatar_url(hash_key, medium=medium)
assert email is not None
return _get_unversioned_gravatar_url(email, medium)
diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py
index d661c500d2e..6b690602876 100644
--- a/zerver/lib/upload/__init__.py
+++ b/zerver/lib/upload/__init__.py
@@ -66,6 +66,10 @@ def delete_message_image(path_id: str) -> bool:
return upload_backend.delete_message_image(path_id)
+def get_avatar_url(hash_key: str, medium: bool = False) -> str:
+ return upload_backend.get_avatar_url(hash_key, medium)
+
+
def upload_avatar_image(
user_file: IO[bytes],
acting_user_profile: UserProfile,