Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Remove undocumented device from /pushrules #14726

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/14682.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable sending confirmation email when 3pid is disabled.
5 changes: 1 addition & 4 deletions synapse/push/clientformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def format_push_rules_for_user(
"""Converts a list of rawrules and a enabled map into nested dictionaries
to match the Matrix client-server format for push rules"""

rules: Dict[str, Dict[str, List[Dict[str, Any]]]] = {
"global": {},
"device": {},
}
rules: Dict[str, Dict[str, List[Dict[str, Any]]]] = {"global": {}}

rules["global"] = _add_empty_priority_class_arrays(rules["global"])

Expand Down
5 changes: 5 additions & 0 deletions synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ def __init__(self, hs: "HomeServer"):
)

async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
if not self.hs.config.registration.enable_3pid_changes:
raise SynapseError(
400, "3PID changes are disabled on this server", Codes.FORBIDDEN
)

if not self.config.email.can_verify_email:
logger.warning(
"Adding emails have been disabled due to lack of an email config"
Expand Down
30 changes: 5 additions & 25 deletions tests/rest/client/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,41 +690,21 @@ def test_add_email_if_disabled(self) -> None:
self.hs.config.registration.enable_3pid_changes = False

client_secret = "foobar"
session_id = self._request_token(self.email, client_secret)

self.assertEqual(len(self.email_attempts), 1)
link = self._get_link_from_email()

self._validate_token(link)

channel = self.make_request(
"POST",
b"/_matrix/client/unstable/account/3pid/add",
b"/_matrix/client/unstable/account/3pid/email/requestToken",
{
"client_secret": client_secret,
"sid": session_id,
"auth": {
"type": "m.login.password",
"user": self.user_id,
"password": "test",
},
"email": "test@example.com",
"send_attempt": 1,
},
access_token=self.user_id_tok,
)

self.assertEqual(
HTTPStatus.BAD_REQUEST, channel.code, msg=channel.result["body"]
)
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])

# Get user
channel = self.make_request(
"GET",
self.url_3pid,
access_token=self.user_id_tok,
)

self.assertEqual(HTTPStatus.OK, channel.code, msg=channel.result["body"])
self.assertFalse(channel.json_body["threepids"])
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])

def test_delete_email(self) -> None:
"""Test deleting an email from profile"""
Expand Down