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.
This commit is contained in:
Steve Howell 2017-10-09 20:23:53 -07:00 committed by Tim Abbott
parent a6c3621f55
commit b0e844c676
1 changed files with 11 additions and 5 deletions

View File

@ -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,