Skip to content

Commit b90ad26

Browse files
authoredDec 4, 2024··
Promote account suspension to stable (#17964)
MSC: matrix-org/matrix-spec-proposals#3823
1 parent a00d0b3 commit b90ad26

File tree

6 files changed

+13
-33
lines changed

6 files changed

+13
-33
lines changed
 

‎changelog.d/17964.feature

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

‎synapse/api/errors.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ class Codes(str, Enum):
100100
# The account has been suspended on the server.
101101
# By opposition to `USER_DEACTIVATED`, this is a reversible measure
102102
# that can possibly be appealed and reverted.
103-
# Part of MSC3823.
104-
USER_ACCOUNT_SUSPENDED = "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
103+
# Introduced by MSC3823
104+
# https://github.com/matrix-org/matrix-spec-proposals/pull/3823
105+
USER_ACCOUNT_SUSPENDED = "M_USER_SUSPENDED"
105106

106107
BAD_ALIAS = "M_BAD_ALIAS"
107108
# For restricted join rules.

‎synapse/config/experimental.py

-4
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
436436
("experimental", "msc4108_delegation_endpoint"),
437437
)
438438

439-
self.msc3823_account_suspension = experimental.get(
440-
"msc3823_account_suspension", False
441-
)
442-
443439
# MSC4151: Report room API (Client-Server API)
444440
self.msc4151_enabled: bool = experimental.get("msc4151_enabled", False)
445441

‎synapse/rest/admin/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
332332
BackgroundUpdateRestServlet(hs).register(http_server)
333333
BackgroundUpdateStartJobRestServlet(hs).register(http_server)
334334
ExperimentalFeaturesRestServlet(hs).register(http_server)
335-
if hs.config.experimental.msc3823_account_suspension:
336-
SuspendAccountRestServlet(hs).register(http_server)
335+
SuspendAccountRestServlet(hs).register(http_server)
337336

338337

339338
def register_servlets_for_client_rest_resource(

‎tests/rest/admin/test_user.py

-1
Original file line numberDiff line numberDiff line change
@@ -5031,7 +5031,6 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
50315031

50325032
self.store = hs.get_datastores().main
50335033

5034-
@override_config({"experimental_features": {"msc3823_account_suspension": True}})
50355034
def test_suspend_user(self) -> None:
50365035
# test that suspending user works
50375036
channel = self.make_request(

‎tests/rest/client/test_rooms.py

+8-24
Original file line numberDiff line numberDiff line change
@@ -1337,17 +1337,13 @@ def test_suspended_user_cannot_join_room(self) -> None:
13371337
"POST", f"/join/{self.room1}", access_token=self.tok2
13381338
)
13391339
self.assertEqual(channel.code, 403)
1340-
self.assertEqual(
1341-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
1342-
)
1340+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
13431341

13441342
channel = self.make_request(
13451343
"POST", f"/rooms/{self.room1}/join", access_token=self.tok2
13461344
)
13471345
self.assertEqual(channel.code, 403)
1348-
self.assertEqual(
1349-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
1350-
)
1346+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
13511347

13521348
def test_suspended_user_cannot_knock_on_room(self) -> None:
13531349
# set the user as suspended
@@ -1361,9 +1357,7 @@ def test_suspended_user_cannot_knock_on_room(self) -> None:
13611357
shorthand=False,
13621358
)
13631359
self.assertEqual(channel.code, 403)
1364-
self.assertEqual(
1365-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
1366-
)
1360+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
13671361

13681362
def test_suspended_user_cannot_invite_to_room(self) -> None:
13691363
# set the user as suspended
@@ -1376,9 +1370,7 @@ def test_suspended_user_cannot_invite_to_room(self) -> None:
13761370
access_token=self.tok1,
13771371
content={"user_id": self.user2},
13781372
)
1379-
self.assertEqual(
1380-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
1381-
)
1373+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
13821374

13831375

13841376
class RoomAppserviceTsParamTestCase(unittest.HomeserverTestCase):
@@ -4011,9 +4003,7 @@ def test_suspended_user_cannot_send_message_to_room(self) -> None:
40114003
access_token=self.tok1,
40124004
content={"body": "hello", "msgtype": "m.text"},
40134005
)
4014-
self.assertEqual(
4015-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
4016-
)
4006+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
40174007

40184008
def test_suspended_user_cannot_change_profile_data(self) -> None:
40194009
# set the user as suspended
@@ -4026,9 +4016,7 @@ def test_suspended_user_cannot_change_profile_data(self) -> None:
40264016
content={"avatar_url": "mxc://matrix.org/wefh34uihSDRGhw34"},
40274017
shorthand=False,
40284018
)
4029-
self.assertEqual(
4030-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
4031-
)
4019+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
40324020

40334021
channel2 = self.make_request(
40344022
"PUT",
@@ -4037,9 +4025,7 @@ def test_suspended_user_cannot_change_profile_data(self) -> None:
40374025
content={"displayname": "something offensive"},
40384026
shorthand=False,
40394027
)
4040-
self.assertEqual(
4041-
channel2.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
4042-
)
4028+
self.assertEqual(channel2.json_body["errcode"], "M_USER_SUSPENDED")
40434029

40444030
def test_suspended_user_cannot_redact_messages_other_than_their_own(self) -> None:
40454031
# first user sends message
@@ -4073,9 +4059,7 @@ def test_suspended_user_cannot_redact_messages_other_than_their_own(self) -> Non
40734059
content={"reason": "bogus"},
40744060
shorthand=False,
40754061
)
4076-
self.assertEqual(
4077-
channel.json_body["errcode"], "ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED"
4078-
)
4062+
self.assertEqual(channel.json_body["errcode"], "M_USER_SUSPENDED")
40794063

40804064
# but can redact their own
40814065
channel = self.make_request(

0 commit comments

Comments
 (0)
Please sign in to comment.