diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-10-09 19:57:50 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-10-09 19:57:50 +0100 |
commit | 0a96a9a02371bd36970db7dfdb2d4c6e98e0200e (patch) | |
tree | 004ddb71a16e93e52b4bff9ffadca31bcc9ba29b /synapse/rest/client/v2_alpha/sync.py | |
parent | Merge branch 'markjh/eventstream_presence' into markjh/v2_sync_api (diff) | |
download | synapse-0a96a9a02371bd36970db7dfdb2d4c6e98e0200e.tar.xz |
Set the user as online if they start polling the v2 sync
Diffstat (limited to 'synapse/rest/client/v2_alpha/sync.py')
-rw-r--r-- | synapse/rest/client/v2_alpha/sync.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py index f20b830eda..3348b46c14 100644 --- a/synapse/rest/client/v2_alpha/sync.py +++ b/synapse/rest/client/v2_alpha/sync.py @@ -79,6 +79,7 @@ class SyncRestServlet(RestServlet): def __init__(self, hs): super(SyncRestServlet, self).__init__() self.auth = hs.get_auth() + self.event_stream_handler = hs.get_handlers().event_stream_handler self.sync_handler = hs.get_handlers().sync_handler self.clock = hs.get_clock() self.filtering = hs.get_filtering() @@ -119,9 +120,16 @@ class SyncRestServlet(RestServlet): else: since_token = None - sync_result = yield self.sync_handler.wait_for_sync_for_user( - sync_config, since_token=since_token, timeout=timeout - ) + if set_presence == "online": + 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() |