From 27128145e67b2c00ff84e7f3d6ca56b03616648b Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 2 Jan 2019 23:37:39 +0000 Subject: [PATCH] fix NPE in /messages by checking if all events were filtered out (#4330) --- changelog.d/4330.bugfix | 1 + synapse/handlers/pagination.py | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 changelog.d/4330.bugfix diff --git a/changelog.d/4330.bugfix b/changelog.d/4330.bugfix new file mode 100644 index 0000000000..666c9022e0 --- /dev/null +++ b/changelog.d/4330.bugfix @@ -0,0 +1 @@ +fix NPE in /messages by checking if all events were filtered out diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index 43f81bd607..9d257ecf31 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -235,6 +235,17 @@ class PaginationHandler(object): "room_key", next_key ) + if events: + if event_filter: + events = event_filter.filter(events) + + events = yield filter_events_for_client( + self.store, + user_id, + events, + is_peeking=(member_event_id is None), + ) + if not events: defer.returnValue({ "chunk": [], @@ -242,16 +253,6 @@ class PaginationHandler(object): "end": next_token.to_string(), }) - if event_filter: - events = event_filter.filter(events) - - events = yield filter_events_for_client( - self.store, - user_id, - events, - is_peeking=(member_event_id is None), - ) - state = None if event_filter and event_filter.lazy_load_members(): # TODO: remove redundant members