mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-01 08:56:04 -04:00
Filter events to only thsoe that the user is allowed to see
This commit is contained in:
parent
f6fde343a1
commit
ca53ad7425
2 changed files with 17 additions and 13 deletions
|
@ -74,7 +74,7 @@ class SearchHandler(BaseHandler):
|
|||
super(SearchHandler, self).__init__(hs)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _filter_events_for_client(self, user_id, room_id, events):
|
||||
def _filter_events_for_client(self, user_id, events):
|
||||
event_id_to_state = yield self.store.get_state_for_events(
|
||||
frozenset(e.event_id for e in events),
|
||||
types=(
|
||||
|
@ -139,16 +139,20 @@ class SearchHandler(BaseHandler):
|
|||
# TODO(paul): work out why because I really don't think it should
|
||||
room_ids = set(r.room_id for r in rooms)
|
||||
|
||||
res = yield self.store.search_msgs(room_ids, constraints)
|
||||
rank_map, event_map = yield self.store.search_msgs(room_ids, constraints)
|
||||
|
||||
allowed_events = yield self._filter_events_for_client(
|
||||
user.to_string(), event_map.values()
|
||||
)
|
||||
|
||||
time_now = self.clock.time_msec()
|
||||
|
||||
results = {
|
||||
r["result"].event_id: {
|
||||
"rank": r["rank"],
|
||||
"result": serialize_event(r["result"], time_now)
|
||||
e.event_id: {
|
||||
"rank": rank_map[e.event_id],
|
||||
"result": serialize_event(e, time_now)
|
||||
}
|
||||
for r in res
|
||||
for e in allowed_events
|
||||
}
|
||||
|
||||
logger.info("returning: %r", results)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue