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

Commit a49b24b

Browse files
committed
fall back to default config setting if not enabled in table
1 parent efeb79c commit a49b24b

File tree

6 files changed

+50
-12
lines changed

6 files changed

+50
-12
lines changed

Diff for: synapse/config/experimental.py

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class ExperimentalConfig(Config):
4343
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
4444
experimental = config.get("experimental_features") or {}
4545

46+
# MSC3026 (busy presence state)
47+
self.msc3026_enabled: bool = experimental.get("msc3026_enabled", False)
48+
4649
# MSC2716 (importing historical messages)
4750
self.msc2716_enabled: bool = experimental.get("msc2716_enabled", False)
4851

@@ -96,6 +99,12 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
9699
# MSC3720 (Account status endpoint)
97100
self.msc3720_enabled: bool = experimental.get("msc3720_enabled", False)
98101

102+
# MSC2654: Unread counts
103+
#
104+
# Note that enabling this will result in an incorrect unread count for
105+
# previously calculated push actions.
106+
self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False)
107+
99108
# MSC2815 (allow room moderators to view redacted event content)
100109
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
101110

@@ -118,6 +127,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
118127
raw_msc3866_config = experimental.get("msc3866", {})
119128
self.msc3866 = MSC3866Config(**raw_msc3866_config)
120129

130+
# MSC3881: Remotely toggle push notifications for another client
131+
self.msc3881_enabled: bool = experimental.get("msc3881_enabled", False)
132+
121133
# MSC3882: Allow an existing session to sign in a new session
122134
self.msc3882_enabled: bool = experimental.get("msc3882_enabled", False)
123135
self.msc3882_ui_auth: bool = experimental.get("msc3882_ui_auth", True)
@@ -174,6 +186,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
174186
"msc3958_supress_edit_notifs", False
175187
)
176188

189+
# MSC3967: Do not require UIA when first uploading cross signing keys
190+
self.msc3967_enabled = experimental.get("msc3967_enabled", False)
191+
177192
# MSC2659: Application service ping endpoint
178193
self.msc2659_enabled = experimental.get("msc2659_enabled", False)
179194

Diff for: synapse/handlers/presence.py

+4
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ async def set_state(
608608
busy_presence_enabled = await self.hs.get_datastores().main.get_feature_enabled(
609609
target_user.to_string(), "msc3026"
610610
)
611+
if not busy_presence_enabled:
612+
busy_presence_enabled = self.hs.config.experimental.msc3026_enabled
611613

612614
if presence not in valid_presence or (
613615
presence == PresenceState.BUSY and not busy_presence_enabled
@@ -1241,6 +1243,8 @@ async def set_state(
12411243
busy_presence_enabled = await self.hs.get_datastores().main.get_feature_enabled(
12421244
target_user.to_string(), "msc3026"
12431245
)
1246+
if not busy_presence_enabled:
1247+
busy_presence_enabled = self.hs.config.experimental.msc3026_enabled
12441248

12451249
if presence not in valid_presence or (
12461250
presence == PresenceState.BUSY and not busy_presence_enabled

Diff for: synapse/push/bulk_push_rule_evaluator.py

+3
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ async def _action_for_event_by_user(
438438

439439
# check whether unread counts are enabled for this user
440440
unread_enabled = await self.store.get_feature_enabled(uid, "msc2654")
441+
if not unread_enabled:
442+
unread_enabled = self.hs.config.experimental.msc2654_enabled
443+
441444
if unread_enabled:
442445
count_as_unread = _should_count_as_unread(event, context)
443446
else:

Diff for: synapse/rest/client/keys.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,13 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
375375
user_id = requester.user.to_string()
376376
body = parse_json_object_from_request(request)
377377

378-
if await self.hs.get_datastores().main.get_feature_enabled(user_id, "msc3967"):
378+
msc3967_enabled = await self.hs.get_datastores().main.get_feature_enabled(
379+
user_id, "msc3967"
380+
)
381+
if not msc3967_enabled:
382+
msc3967_enabled = self.hs.config.experimental.msc2654_enabled
383+
384+
if msc3967_enabled:
379385
if await self.e2e_keys_handler.is_cross_signing_set_up_for_user(user_id):
380386
# If we already have a master key then cross signing is set up and we require UIA to reset
381387
await self.auth_handler.validate_user_via_ui_auth(

Diff for: synapse/rest/client/pusher.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
5353

5454
pusher_dicts = [p.as_dict() for p in pushers]
5555

56+
msc3881_enabled = await self.hs.get_datastores().main.get_feature_enabled(
57+
user.to_string(), "msc3881"
58+
)
59+
if not msc3881_enabled:
60+
msc3881_enabled = self.hs.config.experimental.msc3881_enabled
61+
5662
for pusher in pusher_dicts:
57-
if await self.hs.get_datastores().main.get_feature_enabled(
58-
user.to_string(), "msc3881"
59-
):
63+
if msc3881_enabled:
6064
pusher["org.matrix.msc3881.enabled"] = pusher["enabled"]
6165
pusher["org.matrix.msc3881.device_id"] = pusher["device_id"]
6266
del pusher["enabled"]
@@ -113,12 +117,13 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
113117
append = content["append"]
114118

115119
enabled = True
116-
if (
117-
await self.hs.get_datastores().main.get_feature_enabled(
118-
user.to_string(), "msc3881"
119-
)
120-
and "org.matrix.msc3881.enabled" in content
121-
):
120+
msc3881_enabled = await self.hs.get_datastores().main.get_feature_enabled(
121+
user.to_string(), "msc3881"
122+
)
123+
if not msc3881_enabled:
124+
msc3881_enabled = self.hs.config.experimental.msc3881_enabled
125+
126+
if msc3881_enabled and "org.matrix.msc3881.enabled" in content:
122127
enabled = content["org.matrix.msc3881.enabled"]
123128

124129
if not append:

Diff for: synapse/rest/client/sync.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,14 @@ async def encode_room(
552552
"org.matrix.msc3773.unread_thread_notifications"
553553
] = room.unread_thread_notifications
554554
result["summary"] = room.summary
555-
if await self.store.get_feature_enabled(
555+
556+
msc2654_enabled = await self.hs.get_datastores().main.get_feature_enabled(
556557
requester.user.to_string(), "msc2654"
557-
):
558+
)
559+
if not msc2654_enabled:
560+
msc2654_enabled = self.hs.config.experimental.msc2654_enabled
561+
562+
if msc2654_enabled:
558563
result["org.matrix.msc2654.unread_count"] = room.unread_count
559564

560565
return result

0 commit comments

Comments
 (0)