From 886eceba3e134325e6943aa63eda0a70a7aca911 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:14:52 +0100 Subject: [PATCH 01/10] Return user_type in get_user_by_id --- synapse/handlers/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index a5e23c4caf..97a89fe882 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -24,7 +24,7 @@ from twisted.internet import defer from twisted.internet.defer import succeed from synapse import event_auth -from synapse.api.constants import EventTypes, Membership, RelationTypes +from synapse.api.constants import EventTypes, Membership, RelationTypes, UserTypes from synapse.api.errors import ( AuthError, Codes, @@ -469,6 +469,9 @@ class EventCreationHandler(object): u = yield self.store.get_user_by_id(user_id) assert u is not None + if u["user_type"] == UserTypes.SUPPORT: + # support users are not required to consent + return if u["appservice_id"] is not None: # users registered by an appservice are exempt return From ae38e0569fdb592875b45d4b37f200af5f6a86fc Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:15:10 +0100 Subject: [PATCH 02/10] Ignore consent for support users --- synapse/storage/registration.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index 55e4e84d71..938fd00717 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -56,6 +56,7 @@ class RegistrationWorkerStore(SQLBaseStore): "consent_server_notice_sent", "appservice_id", "creation_ts", + "user_type", ], allow_none=True, desc="get_user_by_id", From 80793e813c7c4024ce28ab9d56d00fd4b4812800 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:20:31 +0100 Subject: [PATCH 03/10] newsfile 5902 --- changelog.d/5902.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5902.feature diff --git a/changelog.d/5902.feature b/changelog.d/5902.feature new file mode 100644 index 0000000000..c1c5c97b18 --- /dev/null +++ b/changelog.d/5902.feature @@ -0,0 +1 @@ +Support users are no longer required to consent. \ No newline at end of file From 0fb5189072f61416e7f616aa9d90d8c981e6b8b3 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:25:35 +0100 Subject: [PATCH 04/10] Fix registration test --- tests/storage/test_registration.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/storage/test_registration.py b/tests/storage/test_registration.py index 0253c4ac05..4578cc3b60 100644 --- a/tests/storage/test_registration.py +++ b/tests/storage/test_registration.py @@ -49,6 +49,7 @@ class RegistrationStoreTestCase(unittest.TestCase): "consent_server_notice_sent": None, "appservice_id": None, "creation_ts": 1000, + "user_type": None, }, (yield self.store.get_user_by_id(self.user_id)), ) From d9b8cf81be1a1132d29e89e3b7d2451886783163 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:52:09 +0100 Subject: [PATCH 05/10] Add bot type --- synapse/api/constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/synapse/api/constants.py b/synapse/api/constants.py index 3ffde0d7fc..f29bce560c 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -122,7 +122,8 @@ class UserTypes(object): """ SUPPORT = "support" - ALL_USER_TYPES = (SUPPORT,) + BOT = "bot" + ALL_USER_TYPES = (SUPPORT, BOT) class RelationTypes(object): From 971c980c6ee4a396a94987c85e5b8db01ceed0d0 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:53:48 +0100 Subject: [PATCH 06/10] Add changelog --- changelog.d/5903.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5903.feature diff --git a/changelog.d/5903.feature b/changelog.d/5903.feature new file mode 100644 index 0000000000..fc60d02107 --- /dev/null +++ b/changelog.d/5903.feature @@ -0,0 +1 @@ +Add bot user type. From 9ba32f6573a47368c1ac63ec769c20f73bcc2cc5 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:56:31 +0100 Subject: [PATCH 07/10] Exempt bot users --- synapse/handlers/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 97a89fe882..c656cffc07 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -469,7 +469,7 @@ class EventCreationHandler(object): u = yield self.store.get_user_by_id(user_id) assert u is not None - if u["user_type"] == UserTypes.SUPPORT: + if u["user_type"] == UserTypes.SUPPORT or u["user_type"] == UserTypes.BOT: # support users are not required to consent return if u["appservice_id"] is not None: From 4a2d2c2b6f42cef95c7e70ecbc27e52b9976fd15 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 23 Aug 2019 09:57:07 +0100 Subject: [PATCH 08/10] Update changelog --- changelog.d/5902.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/5902.feature b/changelog.d/5902.feature index c1c5c97b18..0660f65cfa 100644 --- a/changelog.d/5902.feature +++ b/changelog.d/5902.feature @@ -1 +1 @@ -Support users are no longer required to consent. \ No newline at end of file +Users with the type of "support" or "bot" are no longer required to consent. \ No newline at end of file From c998f250065bd3c0f51a6e6ac3b333ede98ed6a7 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Fri, 23 Aug 2019 10:28:54 +0100 Subject: [PATCH 09/10] Apply suggestions from code review Co-Authored-By: Erik Johnston --- synapse/handlers/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index c656cffc07..111f7c7e2f 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -469,8 +469,8 @@ class EventCreationHandler(object): u = yield self.store.get_user_by_id(user_id) assert u is not None - if u["user_type"] == UserTypes.SUPPORT or u["user_type"] == UserTypes.BOT: - # support users are not required to consent + if u["user_type"] in (UserTypes.SUPPORT, UserTypes.BOT): + # support and bot users are not required to consent return if u["appservice_id"] is not None: # users registered by an appservice are exempt From 5798a134c0a98b9b5b15808a3d1b0e3e63fe4030 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 28 Aug 2019 14:25:05 +0100 Subject: [PATCH 10/10] Removing entry for 5903 --- changelog.d/5903.feature | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changelog.d/5903.feature diff --git a/changelog.d/5903.feature b/changelog.d/5903.feature deleted file mode 100644 index fc60d02107..0000000000 --- a/changelog.d/5903.feature +++ /dev/null @@ -1 +0,0 @@ -Add bot user type.