Set the user as online if they start polling the v2 sync

This commit is contained in:
Mark Haines 2015-10-09 19:57:50 +01:00
parent af7b214476
commit 0a96a9a023
1 changed files with 11 additions and 3 deletions

View File

@ -79,6 +79,7 @@ class SyncRestServlet(RestServlet):
def __init__(self, hs): def __init__(self, hs):
super(SyncRestServlet, self).__init__() super(SyncRestServlet, self).__init__()
self.auth = hs.get_auth() self.auth = hs.get_auth()
self.event_stream_handler = hs.get_handlers().event_stream_handler
self.sync_handler = hs.get_handlers().sync_handler self.sync_handler = hs.get_handlers().sync_handler
self.clock = hs.get_clock() self.clock = hs.get_clock()
self.filtering = hs.get_filtering() self.filtering = hs.get_filtering()
@ -119,9 +120,16 @@ class SyncRestServlet(RestServlet):
else: else:
since_token = None since_token = None
sync_result = yield self.sync_handler.wait_for_sync_for_user( if set_presence == "online":
sync_config, since_token=since_token, timeout=timeout yield self.event_stream_handler.started_stream(user)
)
try:
sync_result = yield self.sync_handler.wait_for_sync_for_user(
sync_config, since_token=since_token, timeout=timeout
)
finally:
if set_presence == "online":
self.event_stream_handler.stopped_stream(user)
time_now = self.clock.time_msec() time_now = self.clock.time_msec()