Add sender_avatar_version to message caches.

We will use this in computing avatar URLs.
This commit is contained in:
Steve Howell 2017-02-16 12:49:21 -08:00 committed by Tim Abbott
parent 3c2c0c67b9
commit 65a4eb8ec8
2 changed files with 5 additions and 1 deletions

View File

@ -79,6 +79,7 @@ class MessageDict(object):
sender_full_name = message.sender.full_name,
sender_short_name = message.sender.short_name,
sender_avatar_source = message.sender.avatar_source,
sender_avatar_version = message.sender.avatar_version,
sender_is_mirror_dummy = message.sender.is_mirror_dummy,
sending_client_name = message.sending_client.name,
recipient_id = message.recipient.id,
@ -112,6 +113,7 @@ class MessageDict(object):
sender_full_name = row['sender__full_name'],
sender_short_name = row['sender__short_name'],
sender_avatar_source = row['sender__avatar_source'],
sender_avatar_version = row['sender__avatar_version'],
sender_is_mirror_dummy = row['sender__is_mirror_dummy'],
sending_client_name = row['sending_client__name'],
recipient_id = row['recipient_id'],
@ -139,6 +141,7 @@ class MessageDict(object):
sender_full_name,
sender_short_name,
sender_avatar_source,
sender_avatar_version,
sender_is_mirror_dummy,
sending_client_name,
recipient_id,
@ -146,7 +149,7 @@ class MessageDict(object):
recipient_type_id,
reactions
):
# type: (bool, Optional[Message], int, Optional[datetime.datetime], Optional[Text], Text, Text, datetime.datetime, Optional[Text], Optional[int], int, Text, int, Text, Text, Text, Text, bool, Text, int, int, int, List[Dict[str, Any]]) -> Dict[str, Any]
# type: (bool, Optional[Message], int, Optional[datetime.datetime], Optional[Text], Text, Text, datetime.datetime, Optional[Text], Optional[int], int, Text, int, Text, Text, Text, Text, int, bool, Text, int, int, int, List[Dict[str, Any]]) -> Dict[str, Any]
avatar_url = get_avatar_url(sender_avatar_source, sender_email)

View File

@ -983,6 +983,7 @@ class Message(ModelReprMixin, models.Model):
'sender__realm__id',
'sender__realm__domain',
'sender__avatar_source',
'sender__avatar_version',
'sender__is_mirror_dummy',
]
messages = Message.objects.filter(id__in=needed_ids).values(*fields)