mirror of https://github.com/zulip/zulip.git
Proprely handle get_old_messages when narrowed to personals with yourself
(imported from commit 3ace5655d093f4568b4dea512a6e1bbbd6245f10)
This commit is contained in:
parent
ed0cb0a5f8
commit
5ea4e30caf
|
@ -261,6 +261,12 @@ def get_old_messages_backend(request, anchor = POST(converter=to_non_negative_in
|
||||||
query = query.filter(recipient__type=Recipient.PERSONAL)
|
query = query.filter(recipient__type=Recipient.PERSONAL)
|
||||||
recipient_user = UserProfile.objects.get(user__email = narrow['one_on_one_email'])
|
recipient_user = UserProfile.objects.get(user__email = narrow['one_on_one_email'])
|
||||||
recipient = Recipient.objects.get(type=Recipient.PERSONAL, type_id=recipient_user.id)
|
recipient = Recipient.objects.get(type=Recipient.PERSONAL, type_id=recipient_user.id)
|
||||||
|
# If we are narrowed to personals with ourself, we want to search for personals where the user
|
||||||
|
# with address "one_on_one_email" is the sender *and* the recipient, not personals where the user
|
||||||
|
# with address "one_on_one_email is the sender *or* the recipient.
|
||||||
|
if narrow['one_on_one_email'] == user_profile.user.email:
|
||||||
|
query = query.filter(Q(sender__user__email=narrow['one_on_one_email']) & Q(recipient=recipient))
|
||||||
|
else:
|
||||||
query = query.filter(Q(sender__user__email=narrow['one_on_one_email']) | Q(recipient=recipient))
|
query = query.filter(Q(sender__user__email=narrow['one_on_one_email']) | Q(recipient=recipient))
|
||||||
elif 'type' in narrow and (narrow['type'] == "huddle" or narrow['type'] == "all_huddles"):
|
elif 'type' in narrow and (narrow['type'] == "huddle" or narrow['type'] == "all_huddles"):
|
||||||
query = query.filter(Q(recipient__type=Recipient.PERSONAL) | Q(recipient__type=Recipient.HUDDLE))
|
query = query.filter(Q(recipient__type=Recipient.PERSONAL) | Q(recipient__type=Recipient.HUDDLE))
|
||||||
|
|
Loading…
Reference in New Issue