Merge pull request #5902 from matrix-org/hs/exempt-support-users-from-consent

Exempt support users from consent
This commit is contained in:
Will Hunt 2019-08-28 16:31:40 +01:00 committed by GitHub
commit c8fa620d7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 2 deletions

1
changelog.d/5902.feature Normal file
View File

@ -0,0 +1 @@
Users with the type of "support" or "bot" are no longer required to consent.

View File

@ -122,7 +122,8 @@ class UserTypes(object):
""" """
SUPPORT = "support" SUPPORT = "support"
ALL_USER_TYPES = (SUPPORT,) BOT = "bot"
ALL_USER_TYPES = (SUPPORT, BOT)
class RelationTypes(object): class RelationTypes(object):

View File

@ -24,7 +24,7 @@ from twisted.internet import defer
from twisted.internet.defer import succeed from twisted.internet.defer import succeed
from synapse import event_auth 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 ( from synapse.api.errors import (
AuthError, AuthError,
Codes, Codes,
@ -469,6 +469,9 @@ class EventCreationHandler(object):
u = yield self.store.get_user_by_id(user_id) u = yield self.store.get_user_by_id(user_id)
assert u is not None assert u is not None
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: if u["appservice_id"] is not None:
# users registered by an appservice are exempt # users registered by an appservice are exempt
return return

View File

@ -56,6 +56,7 @@ class RegistrationWorkerStore(SQLBaseStore):
"consent_server_notice_sent", "consent_server_notice_sent",
"appservice_id", "appservice_id",
"creation_ts", "creation_ts",
"user_type",
], ],
allow_none=True, allow_none=True,
desc="get_user_by_id", desc="get_user_by_id",

View File

@ -49,6 +49,7 @@ class RegistrationStoreTestCase(unittest.TestCase):
"consent_server_notice_sent": None, "consent_server_notice_sent": None,
"appservice_id": None, "appservice_id": None,
"creation_ts": 1000, "creation_ts": 1000,
"user_type": None,
}, },
(yield self.store.get_user_by_id(self.user_id)), (yield self.store.get_user_by_id(self.user_id)),
) )