mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-01 04:09:07 +01:00
Filter the recent events before applying the limit when doing an initial sync
This commit is contained in:
parent
22dd1cde2d
commit
e97de6d96a
1 changed files with 10 additions and 11 deletions
|
@ -163,12 +163,11 @@ class SyncHandler(BaseHandler):
|
||||||
Returns:
|
Returns:
|
||||||
A Deferred RoomSyncResult.
|
A Deferred RoomSyncResult.
|
||||||
"""
|
"""
|
||||||
recent_events, token = yield self.store.get_recent_events_for_room(
|
|
||||||
room_id,
|
recents, prev_batch_token, limited = self.load_filtered_recents(
|
||||||
limit=sync_config.limit,
|
room_id, sync_config, now_token,
|
||||||
end_token=now_token.room_key,
|
|
||||||
)
|
)
|
||||||
prev_batch_token = now_token.copy_and_replace("room_key", token[0])
|
|
||||||
current_state_events = yield self.state_handler.get_current_state(
|
current_state_events = yield self.state_handler.get_current_state(
|
||||||
room_id
|
room_id
|
||||||
)
|
)
|
||||||
|
@ -176,10 +175,10 @@ class SyncHandler(BaseHandler):
|
||||||
defer.returnValue(RoomSyncResult(
|
defer.returnValue(RoomSyncResult(
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
published=room_id in published_room_ids,
|
published=room_id in published_room_ids,
|
||||||
events=recent_events,
|
events=recents,
|
||||||
prev_batch=prev_batch_token,
|
prev_batch=prev_batch_token,
|
||||||
state=current_state_events,
|
state=current_state_events,
|
||||||
limited=True,
|
limited=limited,
|
||||||
ephemeral=[],
|
ephemeral=[],
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -279,8 +278,8 @@ class SyncHandler(BaseHandler):
|
||||||
))
|
))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def load_filtered_recents(self, room_id, sync_config, since_token,
|
def load_filtered_recents(self, room_id, sync_config, now_token,
|
||||||
now_token):
|
since_token=None):
|
||||||
limited = True
|
limited = True
|
||||||
recents = []
|
recents = []
|
||||||
filtering_factor = 2
|
filtering_factor = 2
|
||||||
|
@ -292,7 +291,7 @@ class SyncHandler(BaseHandler):
|
||||||
events, room_key = yield self.store.get_recent_events_for_room(
|
events, room_key = yield self.store.get_recent_events_for_room(
|
||||||
room_id,
|
room_id,
|
||||||
limit=load_limit + 1,
|
limit=load_limit + 1,
|
||||||
from_token=since_token.room_key,
|
from_token=since_token.room_key if since_token else None,
|
||||||
end_token=room_key,
|
end_token=room_key,
|
||||||
)
|
)
|
||||||
loaded_recents = sync_config.filter.filter_room_events(events)
|
loaded_recents = sync_config.filter.filter_room_events(events)
|
||||||
|
@ -328,7 +327,7 @@ class SyncHandler(BaseHandler):
|
||||||
# TODO(mjark): Check for redactions we might have missed.
|
# TODO(mjark): Check for redactions we might have missed.
|
||||||
|
|
||||||
recents, prev_batch_token, limited = self.load_filtered_recents(
|
recents, prev_batch_token, limited = self.load_filtered_recents(
|
||||||
room_id, sync_config, since_token,
|
room_id, sync_config, now_token, since_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.debug("Recents %r", recents)
|
logging.debug("Recents %r", recents)
|
||||||
|
|
Loading…
Reference in a new issue