Remove domain from list of pre-fetched fields for message recipients.

This commit is contained in:
Rishi Gupta 2017-03-13 15:17:41 -07:00 committed by Tim Abbott
parent 5bf01fb7d4
commit 88abb7871d
4 changed files with 2 additions and 6 deletions

View File

@ -99,7 +99,6 @@
'avatar_url': 'https://url/for/othello-bots/avatar', 'avatar_url': 'https://url/for/othello-bots/avatar',
'timestamp': 1375978404, 'timestamp': 1375978404,
'display_recipient': [{'full_name': 'Hamlet of Denmark', 'display_recipient': [{'full_name': 'Hamlet of Denmark',
'domain': 'example.com',
'email': 'hamlet@example.com', 'email': 'hamlet@example.com',
'short_name': 'hamlet', 'short_name': 'hamlet',
'id': 31572}], 'id': 31572}],

View File

@ -703,9 +703,8 @@ def get_recipient_user_profiles(recipient, sender_id):
'user_profile__email', 'user_profile__email',
'user_profile__enable_online_push_notifications', 'user_profile__enable_online_push_notifications',
'user_profile__is_active', 'user_profile__is_active',
'user_profile__realm__domain'
] ]
query = Subscription.objects.select_related("user_profile", "user_profile__realm").only(*fields).filter( query = Subscription.objects.select_related("user_profile").only(*fields).filter(
recipient=recipient, active=True) recipient=recipient, active=True)
recipients = [s.user_profile for s in query] recipients = [s.user_profile for s in query]
else: else:
@ -2846,7 +2845,7 @@ def gather_subscriptions_helper(user_profile, include_subscribers=True):
stream_ids = set([sub["recipient__type_id"] for sub in sub_dicts]) stream_ids = set([sub["recipient__type_id"] for sub in sub_dicts])
all_streams = get_active_streams(user_profile.realm).select_related( all_streams = get_active_streams(user_profile.realm).select_related(
"realm").values("id", "name", "invite_only", "realm_id", "realm").values("id", "name", "invite_only", "realm_id",
"realm__domain", "email_token", "description") "email_token", "description")
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids] stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
stream_hash = {} stream_hash = {}

View File

@ -172,7 +172,6 @@ class MessageDict(object):
# add the sender in if this isn't a message between # add the sender in if this isn't a message between
# someone and his self, preserving ordering # someone and his self, preserving ordering
recip = {'email': sender_email, recip = {'email': sender_email,
'domain': sender_realm_domain,
'full_name': sender_full_name, 'full_name': sender_full_name,
'short_name': sender_short_name, 'short_name': sender_short_name,
'id': sender_id, 'id': sender_id,

View File

@ -93,7 +93,6 @@ def get_display_recipient_remote_cache(recipient_id, recipient_type, recipient_t
.select_related() .select_related()
.order_by('email')) .order_by('email'))
return [{'email': user_profile.email, return [{'email': user_profile.email,
'domain': user_profile.realm.domain,
'full_name': user_profile.full_name, 'full_name': user_profile.full_name,
'short_name': user_profile.short_name, 'short_name': user_profile.short_name,
'id': user_profile.id, 'id': user_profile.id,