Support sender:me and pm-with:me search syntax.

We convert sender:me to sender:steve@zulip.com at parsing time,
so users will see the canonicalization in the search bar.  Likewise
for pm-with.

(imported from commit aa9951f13d4633cfef85f03e5486d607fdef414f)
This commit is contained in:
Steve Howell 2013-12-05 11:35:42 -05:00
parent 5e4e8af0c4
commit 70b0e73a24
2 changed files with 11 additions and 0 deletions

View File

@ -74,6 +74,13 @@ Filter.canonicalize_tuple = function (tuple) {
break;
case 'topic':
break;
case 'sender':
case 'pm-with':
operand = operand.toString().toLowerCase();
if (operand === 'me') {
operand = page_params.email;
}
break;
default:
operand = operand.toString().toLowerCase();
}

View File

@ -8,6 +8,7 @@ add_dependencies({
});
set_global('page_params', {
email: 'hamlet@zulip.com',
domain: 'zulip.com'
});
@ -52,6 +53,9 @@ var Filter = require('js/filter.js');
assert.equal(Filter.canonicalize_operator('Subject'), 'topic');
assert.deepEqual(Filter.canonicalize_tuple(['Stream', 'Denmark']), ['stream', 'Denmark']);
assert.deepEqual(Filter.canonicalize_tuple(['sender', 'me']), ['sender', 'hamlet@zulip.com']);
assert.deepEqual(Filter.canonicalize_tuple(['pm-with', 'me']), ['pm-with', 'hamlet@zulip.com']);
}());
function get_predicate(operators) {