1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

fix syntax

This commit is contained in:
Matthew Hodgson
2016-08-28 23:44:10 +01:00
parent 751ce421cd
commit d46863e199

View File

@@ -34,7 +34,7 @@ function _matches_wildcard(actual_value, filter_value) {
* *
* This is all ported from synapse's Filter object. * This is all ported from synapse's Filter object.
*/ */
FilterComponent = function(filter_json) { function FilterComponent(filter_json) {
this.filter_json = filter_json; this.filter_json = filter_json;
this.types = filter_json.types || null; this.types = filter_json.types || null;
@@ -65,7 +65,7 @@ FilterComponent.prototype.check = function(event) {
event.room_id, event.room_id,
sender, sender,
event.type, event.type,
event.content ? event.content.url !== undefined : false, event.content ? event.content.url !== undefined : false
); );
}; };
@@ -73,38 +73,38 @@ FilterComponent.prototype.check = function(event) {
* Checks whether the filter matches the given event fields. * Checks whether the filter matches the given event fields.
*/ */
FilterComponent.prototype.checkFields = FilterComponent.prototype.checkFields =
function(room_id, sender, event_type, contains_url) { function(room_id, sender, event_type, contains_url)
var literal_keys = { {
"rooms": function(v) { return room_id === v; }, var literal_keys = {
"senders": function(v) { return sender === v; }, "rooms": function(v) { return room_id === v; },
"types": function(v) { return _matches_wildcard(event_type, v); }, "senders": function(v) { return sender === v; },
}; "types": function(v) { return _matches_wildcard(event_type, v); },
};
Object.keys(literal_keys).forEach(function(name) { Object.keys(literal_keys).forEach(function(name) {
var match_func = literal_keys[name]; var match_func = literal_keys[name];
var not_name = "not_" + name; var not_name = "not_" + name;
var disallowed_values = this[not_name]; var disallowed_values = this[not_name];
if (disallowed_values.map(match_func)) { if (disallowed_values.map(match_func)) {
return false; return false;
} }
var allowed_values = this[name]; var allowed_values = this[name];
if (allowed_values) { if (allowed_values) {
if (!allowed_values.map(match_func)) { if (!allowed_values.map(match_func)) {
return false;
}
}
});
contains_url_filter = this.filter_json.contains_url;
if (contains_url_filter !== undefined) {
if (contains_url_filter !== contains_url) {
return false; return false;
} }
} }
});
return true; contains_url_filter = this.filter_json.contains_url;
if (contains_url_filter !== undefined) {
if (contains_url_filter !== contains_url) {
return false;
}
} }
return true;
}; };
FilterComponent.prototype.filter = function(events) { FilterComponent.prototype.filter = function(events) {