diff options
author | Neil Johnson <neil@matrix.org> | 2018-11-14 14:21:41 +0000 |
---|---|---|
committer | Neil Johnson <neil@matrix.org> | 2018-11-14 14:21:41 +0000 |
commit | b58bf8d85010e402e8f78e4323bf7f955605966a (patch) | |
tree | 29a423c5686de5c9673b062a7e3ed403d3631cf7 | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into neilj/create_sup... (diff) | |
download | synapse-b58bf8d85010e402e8f78e4323bf7f955605966a.tar.xz |
tests for support user behaviour
-rw-r--r-- | changelog.d/4141.feature | 2 | ||||
-rw-r--r-- | synapse/handlers/user_directory.py | 38 |
2 files changed, 21 insertions, 19 deletions
diff --git a/changelog.d/4141.feature b/changelog.d/4141.feature index 7df8118d30..34ec4115a7 100644 --- a/changelog.d/4141.feature +++ b/changelog.d/4141.feature @@ -1 +1 @@ -Optionally configure a support user via config for use in verifying user behaviour of a given server, the support user does not appear in user directory or monthly active user counts. +Special case a support user for use in verifying user behaviour of a given server, the support user does not appear in user directory or monthly active user counts. diff --git a/synapse/handlers/user_directory.py b/synapse/handlers/user_directory.py index 821058cfcb..a1f5356268 100644 --- a/synapse/handlers/user_directory.py +++ b/synapse/handlers/user_directory.py @@ -137,8 +137,10 @@ class UserDirectoryHandler(object): """ # FIXME(#3714): We should probably do this in the same worker as all # the other changes. - yield self.store.remove_from_user_dir(user_id) - yield self.store.remove_from_user_in_public_room(user_id) + is_support = yield self.store.is_support_user(user_id) + if not is_support: + yield self.store.remove_from_user_dir(user_id) + yield self.store.remove_from_user_in_public_room(user_id) @defer.inlineCallbacks def _unsafe_process(self): @@ -353,24 +355,24 @@ class UserDirectoryHandler(object): logger.debug("Server is still in room: %r", room_id) is_support = yield self.store.is_support_user(state_key) + if not is_support: + if change is None: + # Handle any profile changes + yield self._handle_profile_change( + state_key, room_id, prev_event_id, event_id, + ) + continue - if change is None and not is_support: - # Handle any profile changes - yield self._handle_profile_change( - state_key, room_id, prev_event_id, event_id, - ) - continue - - if change and not is_support: # The user joined - event = yield self.store.get_event(event_id, allow_none=True) - profile = ProfileInfo( - avatar_url=event.content.get("avatar_url"), - display_name=event.content.get("displayname"), - ) + if change: # The user joined + event = yield self.store.get_event(event_id, allow_none=True) + profile = ProfileInfo( + avatar_url=event.content.get("avatar_url"), + display_name=event.content.get("displayname"), + ) - yield self._handle_new_user(room_id, state_key, profile) - else: # The user left - yield self._handle_remove_user(room_id, state_key) + yield self._handle_new_user(room_id, state_key, profile) + else: # The user left + yield self._handle_remove_user(room_id, state_key) else: logger.debug("Ignoring irrelevant type: %r", typ) |