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

Commit

Permalink
Disable m.3pid_changes capability when MSC3861 is enabled. (#16134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Velten committed Aug 22, 2023
1 parent 69048f7 commit 0ba1777
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog.d/16127.bugfix
@@ -1 +1 @@
User consent features cannot be enabled when using experimental MSC3861.
User constent and 3-PID changes capability cannot be enabled when using experimental [MSC3861](https://github.com/matrix-org/matrix-spec-proposals/pull/3861) support.
1 change: 1 addition & 0 deletions changelog.d/16134.bugfix
@@ -0,0 +1 @@
User constent and 3-PID changes capability cannot be enabled when using experimental [MSC3861](https://github.com/matrix-org/matrix-spec-proposals/pull/3861) support.
6 changes: 6 additions & 0 deletions synapse/config/experimental.py
Expand Up @@ -223,6 +223,12 @@ def check_config_conflicts(self, root: RootConfig) -> None:
("session_lifetime",),
)

if root.registration.enable_3pid_changes:
raise ConfigError(
"enable_3pid_changes cannot be enabled when OAuth delegation is enabled",
("enable_3pid_changes",),
)


@attr.s(auto_attribs=True, frozen=True, slots=True)
class MSC3866Config:
Expand Down
11 changes: 10 additions & 1 deletion synapse/config/registration.py
Expand Up @@ -133,7 +133,16 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:

self.enable_set_displayname = config.get("enable_set_displayname", True)
self.enable_set_avatar_url = config.get("enable_set_avatar_url", True)
self.enable_3pid_changes = config.get("enable_3pid_changes", True)

# The default value of enable_3pid_changes is True, unless msc3861 is enabled.
msc3861_enabled = (
(config.get("experimental_features") or {})
.get("msc3861", {})
.get("enabled", False)
)
self.enable_3pid_changes = config.get(
"enable_3pid_changes", not msc3861_enabled
)

self.disable_msisdn_registration = config.get(
"disable_msisdn_registration", False
Expand Down
5 changes: 5 additions & 0 deletions tests/config/test_oauth_delegation.py
Expand Up @@ -271,3 +271,8 @@ def test_session_lifetime_cannot_be_set(self) -> None:
self.config_dict["session_lifetime"] = "24h"
with self.assertRaises(ConfigError):
self.parse_config()

def test_enable_3pid_changes_cannot_be_enabled(self) -> None:
self.config_dict["enable_3pid_changes"] = True
with self.assertRaises(ConfigError):
self.parse_config()

0 comments on commit 0ba1777

Please sign in to comment.