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.

avatar: Clean up one callsite of deprecated avatar_url_from_dict.

Alex Vandiver35f8c3c4554d
diff --git a/zerver/actions/users.py b/zerver/actions/users.py
index a5c3197fbc5..f9c11d72d42 100644
--- a/zerver/actions/users.py
+++ b/zerver/actions/users.py
@@ -11,7 +11,7 @@ from zerver.actions.user_groups import (
do_send_user_group_members_update_event,
update_users_in_full_members_system_group,
)
-from zerver.lib.avatar import avatar_url_from_dict
+from zerver.lib.avatar import get_avatar_field
from zerver.lib.bot_config import ConfigError, get_bot_config, get_bot_configs, set_bot_config
from zerver.lib.cache import bot_dict_fields
from zerver.lib.create_user import create_user
@@ -670,7 +670,15 @@ def get_owned_bot_dicts(
"default_events_register_stream": botdict["default_events_register_stream__name"],
"default_all_public_streams": botdict["default_all_public_streams"],
"owner_id": botdict["bot_owner_id"],
- "avatar_url": avatar_url_from_dict(botdict),
+ "avatar_url": get_avatar_field(
+ user_id=botdict["id"],
+ realm_id=botdict["realm_id"],
+ email=botdict["email"],
+ avatar_source=botdict["avatar_source"],
+ avatar_version=botdict["avatar_version"],
+ medium=False,
+ client_gravatar=False,
+ ),
"services": services_by_ids[botdict["id"]],
}
for botdict in result
diff --git a/zerver/lib/avatar.py b/zerver/lib/avatar.py
index 4e7882253b4..d23b579bc42 100644
--- a/zerver/lib/avatar.py
+++ b/zerver/lib/avatar.py
@@ -1,4 +1,4 @@
-from typing import Any, Dict, Optional
+from typing import Optional
from urllib.parse import urljoin
from django.conf import settings
@@ -29,24 +29,6 @@ def avatar_url(
)
-def avatar_url_from_dict(userdict: Dict[str, Any], medium: bool = False) -> str:
- """
- DEPRECATED: We should start using
- get_avatar_field to populate users,
- particularly for codepaths where the
- client can compute gravatar URLs
- on the client side.
- """
- url = _get_unversioned_avatar_url(
- userdict["id"],
- userdict["avatar_source"],
- userdict["realm_id"],
- email=userdict["email"],
- medium=medium,
- )
- return append_url_query_string(url, "version={:d}".format(userdict["avatar_version"]))
-
-
def get_avatar_field(
user_id: int,
realm_id: int,