summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-04-21 02:34:58 -0500
committerEric Eastwood <erice@element.io>2022-04-21 02:34:58 -0500
commitaae90dd2420c9e7949050105e0bc723ff1071fa4 (patch)
tree6eadf1793e25a73cf16711fcaecedb42419ceaa6 /synapse
parentFix lints (diff)
downloadsynapse-aae90dd2420c9e7949050105e0bc723ff1071fa4.tar.xz
Nest under MSC3244 room_capabilities field
See https://github.com/matrix-org/synapse/pull/12516#discussion_r854851645
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/room_versions.py35
-rw-r--r--synapse/events/utils.py8
-rw-r--r--synapse/rest/client/capabilities.py6
3 files changed, 5 insertions, 44 deletions
diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py
index 12f00d0a18..3129c8d83e 100644
--- a/synapse/api/room_versions.py
+++ b/synapse/api/room_versions.py
@@ -79,8 +79,6 @@ class RoomVersion:
     # MSC2716: Adds m.room.power_levels -> content.historical field to control
     # whether "insertion", "chunk", "marker" events can be sent
     msc2716_historical: bool
-    # MSC2716: Adds support for redacting "insertion", "chunk", and "marker" events
-    msc2716_redactions: bool
 
 
 class RoomVersions:
@@ -98,7 +96,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V2 = RoomVersion(
         "2",
@@ -114,7 +111,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V3 = RoomVersion(
         "3",
@@ -130,7 +126,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V4 = RoomVersion(
         "4",
@@ -146,7 +141,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V5 = RoomVersion(
         "5",
@@ -162,7 +156,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V6 = RoomVersion(
         "6",
@@ -178,7 +171,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     MSC2176 = RoomVersion(
         "org.matrix.msc2176",
@@ -194,7 +186,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=False,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V7 = RoomVersion(
         "7",
@@ -210,7 +201,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=True,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V8 = RoomVersion(
         "8",
@@ -226,7 +216,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=True,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     V9 = RoomVersion(
         "9",
@@ -242,7 +231,6 @@ class RoomVersions:
         msc3375_redaction_rules=True,
         msc2403_knocking=True,
         msc2716_historical=False,
-        msc2716_redactions=False,
     )
     MSC2716v3 = RoomVersion(
         "org.matrix.msc2716v3",
@@ -258,7 +246,6 @@ class RoomVersions:
         msc3375_redaction_rules=False,
         msc2403_knocking=True,
         msc2716_historical=True,
-        msc2716_redactions=True,
     )
 
 
@@ -311,30 +298,10 @@ MSC3244_CAPABILITIES = {
             RoomVersions.V9,
             lambda room_version: room_version.msc3083_join_rules,
         ),
-    )
-}
-
-MSC2716_CAPABILITIES = {
-    cap.identifier: {
-        "preferred": cap.preferred_version.identifier
-        if cap.preferred_version is not None
-        else None,
-        "support": [
-            v.identifier
-            for v in KNOWN_ROOM_VERSIONS.values()
-            if cap.support_check_lambda(v)
-        ],
-    }
-    for cap in (
         RoomVersionCapability(
-            "historical",
+            "org.matrix.msc2716.historical",
             RoomVersions.MSC2716v3,
             lambda room_version: room_version.msc2716_historical,
         ),
-        RoomVersionCapability(
-            "redactions",
-            RoomVersions.MSC2716v3,
-            lambda room_version: room_version.msc2716_redactions,
-        ),
     )
 }
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index 918e87ed9c..331e00632b 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -49,7 +49,7 @@ if TYPE_CHECKING:
 #       the literal fields "foo\" and "bar" but will instead be treated as "foo\\.bar"
 SPLIT_FIELD_REGEX = re.compile(r"(?<!\\)\.")
 
-CANONICALJSON_MAX_INT = (2**53) - 1
+CANONICALJSON_MAX_INT = (2 ** 53) - 1
 CANONICALJSON_MIN_INT = -CANONICALJSON_MAX_INT
 
 
@@ -157,11 +157,11 @@ def prune_event_dict(room_version: RoomVersion, event_dict: JsonDict) -> JsonDic
         add_fields("history_visibility")
     elif event_type == EventTypes.Redaction and room_version.msc2176_redaction_rules:
         add_fields("redacts")
-    elif room_version.msc2716_redactions and event_type == EventTypes.MSC2716_INSERTION:
+    elif room_version.msc2716_historical and event_type == EventTypes.MSC2716_INSERTION:
         add_fields(EventContentFields.MSC2716_NEXT_BATCH_ID)
-    elif room_version.msc2716_redactions and event_type == EventTypes.MSC2716_BATCH:
+    elif room_version.msc2716_historical and event_type == EventTypes.MSC2716_BATCH:
         add_fields(EventContentFields.MSC2716_BATCH_ID)
-    elif room_version.msc2716_redactions and event_type == EventTypes.MSC2716_MARKER:
+    elif room_version.msc2716_historical and event_type == EventTypes.MSC2716_MARKER:
         add_fields(EventContentFields.MSC2716_MARKER_INSERTION)
 
     allowed_fields = {k: v for k, v in event_dict.items() if k in allowed_keys}
diff --git a/synapse/rest/client/capabilities.py b/synapse/rest/client/capabilities.py
index edd5b59fb7..ee78f93852 100644
--- a/synapse/rest/client/capabilities.py
+++ b/synapse/rest/client/capabilities.py
@@ -17,7 +17,6 @@ from typing import TYPE_CHECKING, Tuple
 
 from synapse.api.room_versions import (
     KNOWN_ROOM_VERSIONS,
-    MSC2716_CAPABILITIES,
     MSC3244_CAPABILITIES,
 )
 from synapse.http.server import HttpServer
@@ -76,11 +75,6 @@ class CapabilitiesRestServlet(RestServlet):
                 "org.matrix.msc3244.room_capabilities"
             ] = MSC3244_CAPABILITIES
 
-        if self.config.experimental.msc2716_enabled:
-            response["capabilities"]["m.room_versions"][
-                "org.matrix.msc2716.room_capabilities"
-            ] = MSC2716_CAPABILITIES
-
         if self.config.experimental.msc3720_enabled:
             response["capabilities"]["org.matrix.msc3720.account_status"] = {
                 "enabled": True,