From dac820f957ed12b5684fa81685d358387be1dfbc Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 7 Sep 2016 22:04:12 +0100 Subject: [PATCH] actually filter /messages --- lib/client.js | 7 +++++++ lib/filter.js | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/client.js b/lib/client.js index 1a514ad08..d4a51938d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1743,6 +1743,13 @@ MatrixClient.prototype.paginateEventTimeline = function(eventTimeline, opts) { dir: dir }; + var filter = eventTimeline.getFilter(); + if (filter) { + // XXX: it's horrific that /messages' filter parameter doesn't match + // /sync's one - see https://matrix.org/jira/browse/SPEC-451 + params.filter = JSON.stringify(filter.getRoomTimelineFilterComponent()); + } + var self = this; var promise = diff --git a/lib/filter.js b/lib/filter.js index 6247592de..d1d31a0bc 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -51,6 +51,14 @@ function Filter(userId, filterId) { this.definition = {}; } +/** + * Get the ID of this filter on your homeserver (if known) + * @return {?Number} The filter ID + */ +Filter.prototype.getFilterId = function() { + return this.filterId; +}; + /** * Get the JSON body of the filter. * @return {Object} The filter definition @@ -126,6 +134,14 @@ Filter.prototype.setDefinition = function(definition) { // this._account_data_filter = new FilterComponent(definition.account_data || {}); }; +/** + * Get the room.timeline filter component of the filter + * @return {FilterComponent} room timeline filter component + */ +Filter.prototype.getRoomTimelineFilterComponent = function() { + return this._room_timeline_filter; +}; + /** * Filter the list of events based on whether they are allowed in a timeline * based on this filter