Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Refactor sync APIs to reuse pagination API #3199

Merged
merged 7 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def handle_room(event):
self.store, user_id, messages
)

start_token = now_token.copy_and_replace("room_key", token[0])
end_token = now_token.copy_and_replace("room_key", token[1])
start_token = now_token.copy_and_replace("room_key", token)
end_token = now_token.copy_and_replace("room_key", room_end_token)
time_now = self.clock.time_msec()

d["messages"] = {
Expand Down Expand Up @@ -325,8 +325,8 @@ def _room_initial_sync_parted(self, user_id, room_id, pagin_config,
self.store, user_id, messages, is_peeking=is_peeking
)

start_token = StreamToken.START.copy_and_replace("room_key", token[0])
end_token = StreamToken.START.copy_and_replace("room_key", token[1])
start_token = StreamToken.START.copy_and_replace("room_key", token)
end_token = StreamToken.START.copy_and_replace("room_key", stream_token)

time_now = self.clock.time_msec()

Expand Down Expand Up @@ -409,7 +409,7 @@ def get_receipts():
)

start_token = now_token.copy_and_replace("room_key", token[0])
end_token = now_token.copy_and_replace("room_key", token[1])
end_token = now_token

time_now = self.clock.time_msec()

Expand Down
21 changes: 14 additions & 7 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,19 @@ def _load_filtered_recents(self, room_id, sync_config, now_token,
since_key = since_token.room_key

while limited and len(recents) < timeline_limit and max_repeat:
events, end_key = yield self.store.get_room_events_stream_for_room(
room_id,
limit=load_limit + 1,
from_key=since_key,
to_key=end_key,
)
if since_key:
events, end_key = yield self.store.get_room_events_stream_for_room(
room_id,
limit=load_limit + 1,
from_key=since_key,
to_key=end_key,
)
else:
events, end_key = yield self.store.get_recent_events_for_room(
room_id,
limit=load_limit + 1,
end_token=end_key,
)
loaded_recents = sync_config.filter_collection.filter_room_timeline(
events
)
Expand Down Expand Up @@ -429,7 +436,7 @@ def get_state_at(self, room_id, stream_position):
Returns:
A Deferred map from ((type, state_key)->Event)
"""
last_events, token = yield self.store.get_recent_events_for_room(
last_events, _ = yield self.store.get_recent_events_for_room(
room_id, end_token=stream_position.room_key, limit=1,
)

Expand Down
Loading