You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
fix filtering
This commit is contained in:
@@ -51,21 +51,15 @@ function FilterComponent(filter_json) {
|
||||
|
||||
/**
|
||||
* Checks with the filter component matches the given event
|
||||
*
|
||||
* Takes a MatrixEvent object
|
||||
*/
|
||||
FilterComponent.prototype.check = function(event) {
|
||||
var sender = event.sender;
|
||||
if (!sender) {
|
||||
// Presence events have their 'sender' in content.user_id
|
||||
if (event.content) {
|
||||
sender = event.content.user_id;
|
||||
}
|
||||
}
|
||||
|
||||
return this.checkFields(
|
||||
event.room_id,
|
||||
sender,
|
||||
event.type,
|
||||
event.content ? event.content.url !== undefined : false
|
||||
event.getRoomId(),
|
||||
event.getSender(),
|
||||
event.getType(),
|
||||
event.getContent() ? event.getContent().url !== undefined : false
|
||||
);
|
||||
};
|
||||
|
||||
@@ -81,15 +75,16 @@ FilterComponent.prototype.checkFields =
|
||||
"types": function(v) { return _matches_wildcard(event_type, v); },
|
||||
};
|
||||
|
||||
var self = this;
|
||||
Object.keys(literal_keys).forEach(function(name) {
|
||||
var match_func = literal_keys[name];
|
||||
var not_name = "not_" + name;
|
||||
var disallowed_values = this[not_name];
|
||||
var disallowed_values = self[not_name];
|
||||
if (disallowed_values.map(match_func)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var allowed_values = this[name];
|
||||
var allowed_values = self[name];
|
||||
if (allowed_values) {
|
||||
if (!allowed_values.map(match_func)) {
|
||||
return false;
|
||||
@@ -108,7 +103,7 @@ FilterComponent.prototype.checkFields =
|
||||
};
|
||||
|
||||
FilterComponent.prototype.filter = function(events) {
|
||||
return events.filter(this.check);
|
||||
return events.filter(this.check, this);
|
||||
};
|
||||
|
||||
FilterComponent.prototype.limit = function() {
|
||||
|
||||
Reference in New Issue
Block a user