Skip to content

Commit

Permalink
Merge 781ba0f into 7e99262
Browse files Browse the repository at this point in the history
  • Loading branch information
cory2067 committed Jun 19, 2017
2 parents 7e99262 + 781ba0f commit 6fd9894
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
13 changes: 13 additions & 0 deletions frontend_tests/node_tests/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ function make_sub(name, stream_id) {
}));
assert(!predicate({type: 'stream'}));

predicate = get_predicate([['pm-with', 'Joe@example.com,steve@foo.com']]);
assert(predicate({
type: 'private',
display_recipient: [{user_id: joe.user_id}, {user_id: steve.user_id}],
}));

// Make sure your own email is ignored
predicate = get_predicate([['pm-with', 'Joe@example.com,steve@foo.com,me@example.com']]);
assert(predicate({
type: 'private',
display_recipient: [{user_id: joe.user_id}, {user_id: steve.user_id}],
}));

predicate = get_predicate([['pm-with', 'nobody@example.com']]);
assert(!predicate({
type: 'private',
Expand Down
8 changes: 7 additions & 1 deletion static/js/narrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,14 @@ exports.by_conversation_and_time_uri = function (message, is_absolute_url) {
"/subject/" + hash_util.encodeHashComponent(message.subject) +
"/near/" + hash_util.encodeHashComponent(message.id);
}

// Include your own email in this URI if it's not there already
var all_emails = message.reply_to;
if (all_emails.indexOf(people.my_current_email()) === -1) {
all_emails += "," + people.my_current_email();
}
return absolute_url + "#narrow/pm-with/" +
hash_util.encodeHashComponent(message.reply_to) +
hash_util.encodeHashComponent(all_emails) +
"/near/" + hash_util.encodeHashComponent(message.id);
};

Expand Down
5 changes: 5 additions & 0 deletions static/js/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ exports.pm_with_operand_ids = function (operand) {
return people_dict.get(email);
});

// If your email is included in a PM group with other people, just ignore it
if (persons.length > 1) {
persons = _.without(persons, people_by_user_id_dict.get(my_user_id));
}

if (!_.all(persons)) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion zerver/views/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def by_pm_with(self, query, operand, maybe_negate):
if ',' in operand:
# Huddle
try:
emails = [e.strip() for e in operand.split(',')]
# Ignore our own email if it is in this list
emails = [e.strip() for e in operand.split(',') if e.strip() != self.user_profile.email]
recipient = recipient_for_emails(emails, False,
self.user_profile, self.user_profile)
except ValidationError:
Expand Down

0 comments on commit 6fd9894

Please sign in to comment.