mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Add filter.is_pm_with_only().
This commit is contained in:
@@ -676,6 +676,7 @@ function make_sub(name, stream_id) {
|
||||
var filter = new Filter(terms);
|
||||
assert.equal(filter.is_stream_only(), true);
|
||||
assert.equal(filter.is_stream_topic_only(), false);
|
||||
assert.equal(filter.is_pm_with_only(), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: 'My Stream'},
|
||||
@@ -684,6 +685,7 @@ function make_sub(name, stream_id) {
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_stream_only(), false);
|
||||
assert.equal(filter.is_stream_topic_only(), true);
|
||||
assert.equal(filter.is_pm_with_only(), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'stream', operand: 'My Stream', negated: true},
|
||||
@@ -692,6 +694,23 @@ function make_sub(name, stream_id) {
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_stream_only(), false);
|
||||
assert.equal(filter.is_stream_topic_only(), false);
|
||||
assert.equal(filter.is_pm_with_only(), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'pm-with', operand: 'foo@example.com', negated: true},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_stream_only(), false);
|
||||
assert.equal(filter.is_stream_topic_only(), false);
|
||||
assert.equal(filter.is_pm_with_only(), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'pm-with', operand: 'foo@example.com,bar@example.com'},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_stream_only(), false);
|
||||
assert.equal(filter.is_stream_topic_only(), false);
|
||||
assert.equal(filter.is_pm_with_only(), true);
|
||||
}());
|
||||
|
||||
(function test_update_email() {
|
||||
|
||||
@@ -419,6 +419,20 @@ Filter.prototype = {
|
||||
return this.has_operator('stream') && this.has_operator('topic');
|
||||
},
|
||||
|
||||
is_pm_with_only: function () {
|
||||
if (this._operators.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var term = this._operators[0];
|
||||
|
||||
if (term.negated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (term.operator === 'pm-with');
|
||||
},
|
||||
|
||||
update_email: function (user_id, new_email) {
|
||||
_.each(this._operators, function (term) {
|
||||
switch (term.operator) {
|
||||
|
||||
Reference in New Issue
Block a user