From ae5bb32ad0d50b90c5d3833e132dc4ba58a4eb86 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 4 Nov 2018 23:46:11 +0000 Subject: add im.vector.hide_profile to user account_data --- synapse/storage/profile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 10133f0a4a..3f6b64c40d 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -147,12 +147,12 @@ class ProfileWorkerStore(SQLBaseStore): lock=False # we can do this because user_id has a unique index ) - def set_profile_active(self, user_localpart, active, batchnum): + def set_profile_active(self, user_localpart, active, hide, batchnum): values = { "active": int(active), "batch": batchnum, } - if not active: + if not active and hide: values["avatar_url"] = None values["displayname"] = None return self._simple_upsert( -- cgit 1.5.1 From 08919847c1e80c3d8a3bae2483980e2909083664 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 4 Nov 2018 23:49:57 +0000 Subject: fix sense of 'hide' --- synapse/storage/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 3f6b64c40d..a8fbc604b6 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -152,7 +152,7 @@ class ProfileWorkerStore(SQLBaseStore): "active": int(active), "batch": batchnum, } - if not active and hide: + if not active and not hide: values["avatar_url"] = None values["displayname"] = None return self._simple_upsert( -- cgit 1.5.1 From 82886e4c8f0a639dba38ba91b625bee12b8c2357 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 12 Dec 2018 00:57:39 +0000 Subject: hide_profile: false should mean not to hide the profile :/ --- synapse/handlers/profile.py | 6 +++--- synapse/rest/client/v2_alpha/account_data.py | 2 +- synapse/storage/profile.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'synapse/storage/profile.py') diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index 58e9181f01..0a952dab97 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -274,9 +274,9 @@ class BaseProfileHandler(BaseHandler): """ Sets the 'active' flag on a user profile. If set to false, the user account is considered deactivated or hidden. - If 'hide' is true, then we just try hide the user rather than deactivate it. - This means withholding it from replication (and mark it as inactive) rather than - clearing the profile from the HS DB. + If 'hide' is true, then we interpret active=False as a request to try to hide the + user rather than deactivating it. This means withholding the profile from replication + (and mark it as inactive) rather than clearing the profile from the HS DB. Note that unlike set_displayname and set_avatar_url, this does *not* perform authorization checks! This is because the only place it's used currently is in account deactivation where we've already done these checks anyway. diff --git a/synapse/rest/client/v2_alpha/account_data.py b/synapse/rest/client/v2_alpha/account_data.py index f4cab67560..21c734e525 100644 --- a/synapse/rest/client/v2_alpha/account_data.py +++ b/synapse/rest/client/v2_alpha/account_data.py @@ -52,7 +52,7 @@ class AccountDataServlet(RestServlet): if account_data_type == "im.vector.hide_profile": user = UserID.from_string(user_id) hide_profile = body.get('hide_profile') - yield self._profile_handler.set_active(user, hide_profile, True) + yield self._profile_handler.set_active(user, not hide_profile, True) max_id = yield self.store.add_account_data_for_user( user_id, account_data_type, body diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index a8fbc604b6..488e31c8b2 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -153,6 +153,8 @@ class ProfileWorkerStore(SQLBaseStore): "batch": batchnum, } if not active and not hide: + # we are deactivating for real (not in hide mode) + # so clear the profile. values["avatar_url"] = None values["displayname"] = None return self._simple_upsert( -- cgit 1.5.1