mirror of
https://github.com/element-hq/synapse
synced 2024-09-17 18:55:10 +00:00
Implement 'synced' flag
This commit is contained in:
parent
839088e2e7
commit
baab93b0dd
2 changed files with 12 additions and 5 deletions
|
@ -97,6 +97,7 @@ class JoinedSyncResult(collections.namedtuple("JoinedSyncResult", [
|
||||||
"ephemeral",
|
"ephemeral",
|
||||||
"account_data",
|
"account_data",
|
||||||
"unread_notifications",
|
"unread_notifications",
|
||||||
|
"synced", # bool
|
||||||
])):
|
])):
|
||||||
__slots__ = []
|
__slots__ = []
|
||||||
|
|
||||||
|
@ -781,13 +782,16 @@ class SyncHandler(object):
|
||||||
continue
|
continue
|
||||||
if r.room_id in include_map:
|
if r.room_id in include_map:
|
||||||
since = include_map[r.room_id].get("since", None)
|
since = include_map[r.room_id].get("since", None)
|
||||||
r.since_token = since
|
if since:
|
||||||
if not since:
|
tok = SyncNextBatchToken.from_string(since)
|
||||||
|
r.since_token = tok.stream_token
|
||||||
|
else:
|
||||||
|
r.since_token = None
|
||||||
r.always_include = True
|
r.always_include = True
|
||||||
r.full_state = True
|
r.full_state = True
|
||||||
r.would_require_resync = True
|
r.would_require_resync = True
|
||||||
r.events = None
|
r.events = None
|
||||||
r.upto_token = now_token
|
r.synced = False
|
||||||
else:
|
else:
|
||||||
r.full_state = True
|
r.full_state = True
|
||||||
r.would_require_resync = True
|
r.would_require_resync = True
|
||||||
|
@ -1201,6 +1205,7 @@ class SyncHandler(object):
|
||||||
ephemeral=ephemeral,
|
ephemeral=ephemeral,
|
||||||
account_data=account_data_events,
|
account_data=account_data_events,
|
||||||
unread_notifications=unread_notifications,
|
unread_notifications=unread_notifications,
|
||||||
|
synced=room_builder.synced,
|
||||||
)
|
)
|
||||||
|
|
||||||
if room_sync or always_include:
|
if room_sync or always_include:
|
||||||
|
@ -1391,7 +1396,7 @@ class RoomSyncResultBuilder(object):
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
"room_id", "rtype", "events", "newly_joined", "full_state", "since_token",
|
"room_id", "rtype", "events", "newly_joined", "full_state", "since_token",
|
||||||
"upto_token", "always_include", "would_require_resync",
|
"upto_token", "always_include", "would_require_resync", "synced",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, room_id, rtype, events, newly_joined, full_state,
|
def __init__(self, room_id, rtype, events, newly_joined, full_state,
|
||||||
|
@ -1416,3 +1421,4 @@ class RoomSyncResultBuilder(object):
|
||||||
self.upto_token = upto_token
|
self.upto_token = upto_token
|
||||||
self.always_include = False
|
self.always_include = False
|
||||||
self.would_require_resync = False
|
self.would_require_resync = False
|
||||||
|
self.synced = True
|
||||||
|
|
|
@ -335,6 +335,7 @@ class SyncRestServlet(RestServlet):
|
||||||
joined[room.room_id] = self.encode_room(
|
joined[room.room_id] = self.encode_room(
|
||||||
room, time_now, token_id
|
room, time_now, token_id
|
||||||
)
|
)
|
||||||
|
joined[room.room_id]["synced"] = room.synced
|
||||||
|
|
||||||
return joined
|
return joined
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue