diff --git a/lib/filter-component.js b/lib/filter-component.js index 3930806f6..8534d420d 100644 --- a/lib/filter-component.js +++ b/lib/filter-component.js @@ -34,7 +34,7 @@ function _matches_wildcard(actual_value, filter_value) { * * This is all ported from synapse's Filter object. */ -FilterComponent = function(filter_json) { +function FilterComponent(filter_json) { this.filter_json = filter_json; this.types = filter_json.types || null; @@ -65,7 +65,7 @@ FilterComponent.prototype.check = function(event) { event.room_id, sender, 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. */ FilterComponent.prototype.checkFields = - function(room_id, sender, event_type, contains_url) { - var literal_keys = { - "rooms": function(v) { return room_id === v; }, - "senders": function(v) { return sender === v; }, - "types": function(v) { return _matches_wildcard(event_type, v); }, - }; + function(room_id, sender, event_type, contains_url) +{ + var literal_keys = { + "rooms": function(v) { return room_id === v; }, + "senders": function(v) { return sender === v; }, + "types": function(v) { return _matches_wildcard(event_type, v); }, + }; - Object.keys(literal_keys).forEach(function(name) { - var match_func = literal_keys[name]; - var not_name = "not_" + name; - var disallowed_values = this[not_name]; - if (disallowed_values.map(match_func)) { - return false; - } + Object.keys(literal_keys).forEach(function(name) { + var match_func = literal_keys[name]; + var not_name = "not_" + name; + var disallowed_values = this[not_name]; + if (disallowed_values.map(match_func)) { + return false; + } - var allowed_values = this[name]; - if (allowed_values) { - 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) { + var allowed_values = this[name]; + if (allowed_values) { + if (!allowed_values.map(match_func)) { 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) {