From 43bb12e640ce1563541b246bffe09870d43892ea Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 5 May 2017 11:02:34 +0100 Subject: [PATCH] Disable presence This reverts commit 0ebd376a53bb75ade6d65db2d716478758c2c9f0 and disables presence a bit more --- synapse/app/synchrotron.py | 1 + synapse/handlers/initial_sync.py | 1 + synapse/handlers/presence.py | 3 +++ synapse/handlers/sync.py | 2 +- synapse/rest/client/v1/presence.py | 2 +- tests/rest/client/v1/test_rooms.py | 12 +++++++----- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/synapse/app/synchrotron.py b/synapse/app/synchrotron.py index 82f06ea185ed..3cade3c68ebe 100644 --- a/synapse/app/synchrotron.py +++ b/synapse/app/synchrotron.py @@ -116,6 +116,7 @@ def __init__(self, hs): logger.info("Presence process_id is %r", self.process_id) def send_user_sync(self, user_id, is_syncing, last_sync_ms): + return self.hs.get_tcp_replication().send_user_sync(user_id, is_syncing, last_sync_ms) def mark_as_coming_online(self, user_id): diff --git a/synapse/handlers/initial_sync.py b/synapse/handlers/initial_sync.py index 71af86fe2131..5242309c1eab 100644 --- a/synapse/handlers/initial_sync.py +++ b/synapse/handlers/initial_sync.py @@ -373,6 +373,7 @@ def _room_initial_sync_joined(self, user_id, room_id, pagin_config, @defer.inlineCallbacks def get_presence(): + defer.returnValue([]) states = yield presence_handler.get_states( [m.user_id for m in room_members], as_event=True, diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 7fe568132fb8..c7336020a253 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -391,6 +391,7 @@ def bump_presence_active_time(self, user): """We've seen the user do something that indicates they're interacting with the app. """ + return user_id = user.to_string() bump_active_time_counter.inc() @@ -420,6 +421,7 @@ def user_syncing(self, user_id, affect_presence=True): Useful for streams that are not associated with an actual client that is being used by a user. """ + affect_presence = False if affect_presence: curr_sync = self.user_to_num_current_syncs.get(user_id, 0) self.user_to_num_current_syncs[user_id] = curr_sync + 1 @@ -465,6 +467,7 @@ def get_currently_syncing_users(self): Returns: set(str): A set of user_id strings. """ + return set() syncing_user_ids = { user_id for user_id, count in self.user_to_num_current_syncs.items() if count diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 51ec727df065..1e8a50514b45 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -620,7 +620,7 @@ def generate_sync_result(self, sync_config, since_token=None, full_state=False): since_token is None and sync_config.filter_collection.blocks_all_presence() ) - if not block_all_presence_data: + if False and not block_all_presence_data: yield self._generate_sync_entry_for_presence( sync_result_builder, newly_joined_rooms, newly_joined_users ) diff --git a/synapse/rest/client/v1/presence.py b/synapse/rest/client/v1/presence.py index 647994bd53da..a975666d1285 100644 --- a/synapse/rest/client/v1/presence.py +++ b/synapse/rest/client/v1/presence.py @@ -83,7 +83,7 @@ def on_PUT(self, request, user_id): except Exception: raise SynapseError(400, "Unable to parse state") - yield self.presence_handler.set_state(user, state) + # yield self.presence_handler.set_state(user, state) defer.returnValue((200, {})) diff --git a/tests/rest/client/v1/test_rooms.py b/tests/rest/client/v1/test_rooms.py index 61d737725be7..5bc0ba19347c 100644 --- a/tests/rest/client/v1/test_rooms.py +++ b/tests/rest/client/v1/test_rooms.py @@ -984,11 +984,13 @@ def test_initial_sync(self): self.assertTrue("presence" in response) - presence_by_user = { - e["content"]["user_id"]: e for e in response["presence"] - } - self.assertTrue(self.user_id in presence_by_user) - self.assertEquals("m.presence", presence_by_user[self.user_id]["type"]) + # presence is turned off on hotfixes + + # presence_by_user = { + # e["content"]["user_id"]: e for e in response["presence"] + # } + # self.assertTrue(self.user_id in presence_by_user) + # self.assertEquals("m.presence", presence_by_user[self.user_id]["type"]) class RoomMessageListTestCase(RestTestCase):