From b0e844c67687b13994299cc0e5b54cc70d133700 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 9 Oct 2017 20:23:53 -0700 Subject: [PATCH] refactor: Use get_avatar_field in message.py. This is part of deprecating avatar_url_from_dict and eventually supporting the client_gravatar field in message-related requests from clients. --- zerver/lib/message.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/zerver/lib/message.py b/zerver/lib/message.py index b281800c2e..db5df690dc 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -7,7 +7,7 @@ from django.utils.translation import ugettext as _ from django.utils.timezone import now as timezone_now from six import binary_type -from zerver.lib.avatar import avatar_url_from_dict +from zerver.lib.avatar import get_avatar_field import zerver.lib.bugdown as bugdown from zerver.lib.cache import cache_with_key, to_dict_cache_key from zerver.lib.request import JsonableError @@ -169,12 +169,18 @@ class MessageDict(object): ): # type: (bool, Optional[Message], int, Optional[datetime.datetime], Optional[Text], Text, Text, datetime.datetime, Optional[Text], Optional[int], int, Text, int, Text, Text, int, bool, Text, int, int, int, List[Dict[str, Any]]) -> Dict[str, Any] - avatar_url = avatar_url_from_dict(dict( + # TODO: Make client_gravatar configurable. + client_gravatar = False + + avatar_url = get_avatar_field( + user_id=sender_id, + realm_id=sender_realm_id, + email=sender_email, avatar_source=sender_avatar_source, avatar_version=sender_avatar_version, - email=sender_email, - id=sender_id, - realm_id=sender_realm_id)) + medium=False, + client_gravatar=client_gravatar, + ) obj = dict( id = message_id,