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

Add MSC2716 to room capabilities #12516

Closed
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/12516.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Expose [MSC2716](https://github.com/matrix-org/matrix-spec-proposals/pull/2716) room capabilities (`/capabilities` endpoint).
18 changes: 5 additions & 13 deletions synapse/api/room_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -98,7 +96,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V2 = RoomVersion(
"2",
Expand All @@ -114,7 +111,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V3 = RoomVersion(
"3",
Expand All @@ -130,7 +126,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V4 = RoomVersion(
"4",
Expand All @@ -146,7 +141,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V5 = RoomVersion(
"5",
Expand All @@ -162,7 +156,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V6 = RoomVersion(
"6",
Expand All @@ -178,7 +171,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
MSC2176 = RoomVersion(
"org.matrix.msc2176",
Expand All @@ -194,7 +186,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=False,
msc2716_historical=False,
msc2716_redactions=False,
)
V7 = RoomVersion(
"7",
Expand All @@ -210,7 +201,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=True,
msc2716_historical=False,
msc2716_redactions=False,
)
V8 = RoomVersion(
"8",
Expand All @@ -226,7 +216,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=True,
msc2716_historical=False,
msc2716_redactions=False,
)
V9 = RoomVersion(
"9",
Expand All @@ -242,7 +231,6 @@ class RoomVersions:
msc3375_redaction_rules=True,
msc2403_knocking=True,
msc2716_historical=False,
msc2716_redactions=False,
)
MSC2716v3 = RoomVersion(
"org.matrix.msc2716v3",
Expand All @@ -258,7 +246,6 @@ class RoomVersions:
msc3375_redaction_rules=False,
msc2403_knocking=True,
msc2716_historical=True,
msc2716_redactions=True,
)


Expand Down Expand Up @@ -311,5 +298,10 @@ class RoomVersionCapability:
RoomVersions.V9,
lambda room_version: room_version.msc3083_join_rules,
),
RoomVersionCapability(
"org.matrix.msc2716.historical",
RoomVersions.MSC2716v3,
lambda room_version: room_version.msc2716_historical,
),
)
}
6 changes: 3 additions & 3 deletions synapse/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def add_fields(*fields: str) -> None:
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}
Expand Down