Fix redacted events being returned in search results ordered by "recent" (#6522)

This commit is contained in:
Andrew Morgan 2019-12-12 15:53:49 +00:00 committed by GitHub
parent 25f1244329
commit 5bfd8855d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

1
changelog.d/6522.bugfix Normal file
View File

@ -0,0 +1 @@
Prevent redacted events from being returned during message search.

View File

@ -385,7 +385,7 @@ class SearchStore(SearchBackgroundUpdateStore):
""" """
clauses = [] clauses = []
search_query = search_query = _parse_query(self.database_engine, search_term) search_query = _parse_query(self.database_engine, search_term)
args = [] args = []
@ -501,7 +501,7 @@ class SearchStore(SearchBackgroundUpdateStore):
""" """
clauses = [] clauses = []
search_query = search_query = _parse_query(self.database_engine, search_term) search_query = _parse_query(self.database_engine, search_term)
args = [] args = []
@ -606,7 +606,12 @@ class SearchStore(SearchBackgroundUpdateStore):
results = list(filter(lambda row: row["room_id"] in room_ids, results)) results = list(filter(lambda row: row["room_id"] in room_ids, results))
events = yield self.get_events_as_list([r["event_id"] for r in results]) # We set redact_behaviour to BLOCK here to prevent redacted events being returned in
# search results (which is a data leak)
events = yield self.get_events_as_list(
[r["event_id"] for r in results],
redact_behaviour=EventRedactBehaviour.BLOCK,
)
event_map = {ev.event_id: ev for ev in events} event_map = {ev.event_id: ev for ev in events}