Promote account suspension to stable (#17964)

MSC: https://github.com/matrix-org/matrix-spec-proposals/pull/3823
This commit is contained in:
Travis Ralston 2024-12-04 16:56:42 -07:00 committed by GitHub
parent a00d0b3d0e
commit b90ad26ebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 13 additions and 33 deletions

View file

@ -0,0 +1 @@
Support stable account suspension from [MSC3823](https://github.com/matrix-org/matrix-spec-proposals/pull/3823).

View file

@ -100,8 +100,9 @@ class Codes(str, Enum):
# The account has been suspended on the server. # The account has been suspended on the server.
# By opposition to `USER_DEACTIVATED`, this is a reversible measure # By opposition to `USER_DEACTIVATED`, this is a reversible measure
# that can possibly be appealed and reverted. # that can possibly be appealed and reverted.
# Part of MSC3823. # Introduced by MSC3823
USER_ACCOUNT_SUSPENDED = "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED" # https://github.com/matrix-org/matrix-spec-proposals/pull/3823
USER_ACCOUNT_SUSPENDED = "M_USER_SUSPENDED"
BAD_ALIAS = "M_BAD_ALIAS" BAD_ALIAS = "M_BAD_ALIAS"
# For restricted join rules. # For restricted join rules.

View file

@ -436,10 +436,6 @@ class ExperimentalConfig(Config):
("experimental", "msc4108_delegation_endpoint"), ("experimental", "msc4108_delegation_endpoint"),
) )
self.msc3823_account_suspension = experimental.get(
"msc3823_account_suspension", False
)
# MSC4151: Report room API (Client-Server API) # MSC4151: Report room API (Client-Server API)
self.msc4151_enabled: bool = experimental.get("msc4151_enabled", False) self.msc4151_enabled: bool = experimental.get("msc4151_enabled", False)

View file

@ -332,8 +332,7 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
BackgroundUpdateRestServlet(hs).register(http_server) BackgroundUpdateRestServlet(hs).register(http_server)
BackgroundUpdateStartJobRestServlet(hs).register(http_server) BackgroundUpdateStartJobRestServlet(hs).register(http_server)
ExperimentalFeaturesRestServlet(hs).register(http_server) ExperimentalFeaturesRestServlet(hs).register(http_server)
if hs.config.experimental.msc3823_account_suspension: SuspendAccountRestServlet(hs).register(http_server)
SuspendAccountRestServlet(hs).register(http_server)
def register_servlets_for_client_rest_resource( def register_servlets_for_client_rest_resource(

View file

@ -5031,7 +5031,6 @@ class UserSuspensionTestCase(unittest.HomeserverTestCase):
self.store = hs.get_datastores().main self.store = hs.get_datastores().main
@override_config({"experimental_features": {"msc3823_account_suspension": True}})
def test_suspend_user(self) -> None: def test_suspend_user(self) -> None:
# test that suspending user works # test that suspending user works
channel = self.make_request( channel = self.make_request(

View file

@ -1337,17 +1337,13 @@ class RoomJoinTestCase(RoomBase):
"POST", f"/join/{self.room1}", access_token=self.tok2 "POST", f"/join/{self.room1}", access_token=self.tok2
) )
self.assertEqual(channel.code, 403) self.assertEqual(channel.code, 403)
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
channel = self.make_request( channel = self.make_request(
"POST", f"/rooms/{self.room1}/join", access_token=self.tok2 "POST", f"/rooms/{self.room1}/join", access_token=self.tok2
) )
self.assertEqual(channel.code, 403) self.assertEqual(channel.code, 403)
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
def test_suspended_user_cannot_knock_on_room(self) -> None: def test_suspended_user_cannot_knock_on_room(self) -> None:
# set the user as suspended # set the user as suspended
@ -1361,9 +1357,7 @@ class RoomJoinTestCase(RoomBase):
shorthand=False, shorthand=False,
) )
self.assertEqual(channel.code, 403) self.assertEqual(channel.code, 403)
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
def test_suspended_user_cannot_invite_to_room(self) -> None: def test_suspended_user_cannot_invite_to_room(self) -> None:
# set the user as suspended # set the user as suspended
@ -1376,9 +1370,7 @@ class RoomJoinTestCase(RoomBase):
access_token=self.tok1, access_token=self.tok1,
content={"user_id": self.user2}, content={"user_id": self.user2},
) )
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
class RoomAppserviceTsParamTestCase(unittest.HomeserverTestCase): class RoomAppserviceTsParamTestCase(unittest.HomeserverTestCase):
@ -4011,9 +4003,7 @@ class UserSuspensionTests(unittest.HomeserverTestCase):
access_token=self.tok1, access_token=self.tok1,
content={"body": "hello", "msgtype": "m.text"}, content={"body": "hello", "msgtype": "m.text"},
) )
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
def test_suspended_user_cannot_change_profile_data(self) -> None: def test_suspended_user_cannot_change_profile_data(self) -> None:
# set the user as suspended # set the user as suspended
@ -4026,9 +4016,7 @@ class UserSuspensionTests(unittest.HomeserverTestCase):
content={"avatar_url": "mxc://matrix.org/wefh34uihSDRGhw34"}, content={"avatar_url": "mxc://matrix.org/wefh34uihSDRGhw34"},
shorthand=False, shorthand=False,
) )
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
channel2 = self.make_request( channel2 = self.make_request(
"PUT", "PUT",
@ -4037,9 +4025,7 @@ class UserSuspensionTests(unittest.HomeserverTestCase):
content={"displayname": "something offensive"}, content={"displayname": "something offensive"},
shorthand=False, shorthand=False,
) )
self.assertEqual( self.assertEqual(channel2.json_body["errcode"], "M_USER_SUSPENDED")
channel2.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
def test_suspended_user_cannot_redact_messages_other_than_their_own(self) -> None: def test_suspended_user_cannot_redact_messages_other_than_their_own(self) -> None:
# first user sends message # first user sends message
@ -4073,9 +4059,7 @@ class UserSuspensionTests(unittest.HomeserverTestCase):
content={"reason": "bogus"}, content={"reason": "bogus"},
shorthand=False, shorthand=False,
) )
self.assertEqual( self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
)
# but can redact their own # but can redact their own
channel = self.make_request( channel = self.make_request(