1
0

fall back to default config setting if not enabled in table

This commit is contained in:
H. Shay
2023-05-01 18:36:59 -07:00
parent 842eb40e45
commit e5f33c58cc
6 changed files with 50 additions and 12 deletions

View File

@@ -43,6 +43,9 @@ class ExperimentalConfig(Config):
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
experimental = config.get("experimental_features") or {}
# MSC3026 (busy presence state)
self.msc3026_enabled: bool = experimental.get("msc3026_enabled", False)
# MSC2716 (importing historical messages)
self.msc2716_enabled: bool = experimental.get("msc2716_enabled", False)
@@ -96,6 +99,12 @@ class ExperimentalConfig(Config):
# MSC3720 (Account status endpoint)
self.msc3720_enabled: bool = experimental.get("msc3720_enabled", False)
# MSC2654: Unread counts
#
# Note that enabling this will result in an incorrect unread count for
# previously calculated push actions.
self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False)
# MSC2815 (allow room moderators to view redacted event content)
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
@@ -118,6 +127,9 @@ class ExperimentalConfig(Config):
raw_msc3866_config = experimental.get("msc3866", {})
self.msc3866 = MSC3866Config(**raw_msc3866_config)
# MSC3881: Remotely toggle push notifications for another client
self.msc3881_enabled: bool = experimental.get("msc3881_enabled", False)
# MSC3882: Allow an existing session to sign in a new session
self.msc3882_enabled: bool = experimental.get("msc3882_enabled", False)
self.msc3882_ui_auth: bool = experimental.get("msc3882_ui_auth", True)
@@ -174,6 +186,9 @@ class ExperimentalConfig(Config):
"msc3958_supress_edit_notifs", False
)
# MSC3967: Do not require UIA when first uploading cross signing keys
self.msc3967_enabled = experimental.get("msc3967_enabled", False)
# MSC2659: Application service ping endpoint
self.msc2659_enabled = experimental.get("msc2659_enabled", False)

View File

@@ -608,6 +608,8 @@ class WorkerPresenceHandler(BasePresenceHandler):
busy_presence_enabled = await self.hs.get_datastores().main.get_feature_enabled(
target_user.to_string(), "msc3026"
)
if not busy_presence_enabled:
busy_presence_enabled = self.hs.config.experimental.msc3026_enabled
if presence not in valid_presence or (
presence == PresenceState.BUSY and not busy_presence_enabled
@@ -1241,6 +1243,8 @@ class PresenceHandler(BasePresenceHandler):
busy_presence_enabled = await self.hs.get_datastores().main.get_feature_enabled(
target_user.to_string(), "msc3026"
)
if not busy_presence_enabled:
busy_presence_enabled = self.hs.config.experimental.msc3026_enabled
if presence not in valid_presence or (
presence == PresenceState.BUSY and not busy_presence_enabled

View File

@@ -438,6 +438,9 @@ class BulkPushRuleEvaluator:
# check whether unread counts are enabled for this user
unread_enabled = await self.store.get_feature_enabled(uid, "msc2654")
if not unread_enabled:
unread_enabled = self.hs.config.experimental.msc2654_enabled
if unread_enabled:
count_as_unread = _should_count_as_unread(event, context)
else:

View File

@@ -375,7 +375,13 @@ class SigningKeyUploadServlet(RestServlet):
user_id = requester.user.to_string()
body = parse_json_object_from_request(request)
if await self.hs.get_datastores().main.get_feature_enabled(user_id, "msc3967"):
msc3967_enabled = await self.hs.get_datastores().main.get_feature_enabled(
user_id, "msc3967"
)
if not msc3967_enabled:
msc3967_enabled = self.hs.config.experimental.msc2654_enabled
if msc3967_enabled:
if await self.e2e_keys_handler.is_cross_signing_set_up_for_user(user_id):
# If we already have a master key then cross signing is set up and we require UIA to reset
await self.auth_handler.validate_user_via_ui_auth(

View File

@@ -53,10 +53,14 @@ class PushersRestServlet(RestServlet):
pusher_dicts = [p.as_dict() for p in pushers]
msc3881_enabled = await self.hs.get_datastores().main.get_feature_enabled(
user.to_string(), "msc3881"
)
if not msc3881_enabled:
msc3881_enabled = self.hs.config.experimental.msc3881_enabled
for pusher in pusher_dicts:
if await self.hs.get_datastores().main.get_feature_enabled(
user.to_string(), "msc3881"
):
if msc3881_enabled:
pusher["org.matrix.msc3881.enabled"] = pusher["enabled"]
pusher["org.matrix.msc3881.device_id"] = pusher["device_id"]
del pusher["enabled"]
@@ -113,12 +117,13 @@ class PushersSetRestServlet(RestServlet):
append = content["append"]
enabled = True
if (
await self.hs.get_datastores().main.get_feature_enabled(
user.to_string(), "msc3881"
)
and "org.matrix.msc3881.enabled" in content
):
msc3881_enabled = await self.hs.get_datastores().main.get_feature_enabled(
user.to_string(), "msc3881"
)
if not msc3881_enabled:
msc3881_enabled = self.hs.config.experimental.msc3881_enabled
if msc3881_enabled and "org.matrix.msc3881.enabled" in content:
enabled = content["org.matrix.msc3881.enabled"]
if not append:

View File

@@ -552,9 +552,14 @@ class SyncRestServlet(RestServlet):
"org.matrix.msc3773.unread_thread_notifications"
] = room.unread_thread_notifications
result["summary"] = room.summary
if await self.store.get_feature_enabled(
msc2654_enabled = await self.hs.get_datastores().main.get_feature_enabled(
requester.user.to_string(), "msc2654"
):
)
if not msc2654_enabled:
msc2654_enabled = self.hs.config.experimental.msc2654_enabled
if msc2654_enabled:
result["org.matrix.msc2654.unread_count"] = room.unread_count
return result