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

code_spécifique_watcha
Andrew Morgan 5 years ago committed by GitHub
parent 25f1244329
commit 5bfd8855d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      changelog.d/6522.bugfix
  2. 11
      synapse/storage/data_stores/main/search.py

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

@ -385,7 +385,7 @@ class SearchStore(SearchBackgroundUpdateStore):
"""
clauses = []
search_query = search_query = _parse_query(self.database_engine, search_term)
search_query = _parse_query(self.database_engine, search_term)
args = []
@ -501,7 +501,7 @@ class SearchStore(SearchBackgroundUpdateStore):
"""
clauses = []
search_query = search_query = _parse_query(self.database_engine, search_term)
search_query = _parse_query(self.database_engine, search_term)
args = []
@ -606,7 +606,12 @@ class SearchStore(SearchBackgroundUpdateStore):
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}

Loading…
Cancel
Save