mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
Add filter.is_for_only(operand).
This commit is contained in:
@@ -711,6 +711,37 @@ function make_sub(name, stream_id) {
|
||||
assert.equal(filter.is_stream_only(), false);
|
||||
assert.equal(filter.is_stream_topic_only(), false);
|
||||
assert.equal(filter.is_pm_with_only(), true);
|
||||
assert.equal(filter.is_for_only('mentioned'), false);
|
||||
assert.equal(filter.is_for_only('private'), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'private'},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_for_only('mentioned'), false);
|
||||
assert.equal(filter.is_for_only('private'), true);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'mentioned'},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_for_only('mentioned'), true);
|
||||
assert.equal(filter.is_for_only('private'), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'mentioned'},
|
||||
{operator: 'is', operand: 'starred'},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_for_only('mentioned'), false);
|
||||
assert.equal(filter.is_for_only('private'), false);
|
||||
|
||||
terms = [
|
||||
{operator: 'is', operand: 'mentioned', negated: true},
|
||||
];
|
||||
filter = new Filter(terms);
|
||||
assert.equal(filter.is_for_only('mentioned'), false);
|
||||
assert.equal(filter.is_for_only('private'), false);
|
||||
}());
|
||||
|
||||
(function test_update_email() {
|
||||
|
||||
@@ -433,6 +433,28 @@ Filter.prototype = {
|
||||
return (term.operator === 'pm-with');
|
||||
},
|
||||
|
||||
is_for_only: function (operand) {
|
||||
// Call as:
|
||||
// filter.is_for_only('mentioned')
|
||||
// filter.is_for_only('private')
|
||||
// filter.is_for_only('starred')
|
||||
if (this._operators.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var term = this._operators[0];
|
||||
|
||||
if (term.negated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (term.operator !== 'is') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (term.operand === operand);
|
||||
},
|
||||
|
||||
update_email: function (user_id, new_email) {
|
||||
_.each(this._operators, function (term) {
|
||||
switch (term.operator) {
|
||||
|
||||
Reference in New Issue
Block a user