1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan
1b2d50bd25 wip 2022-03-06 10:06:58 +00:00
Andrew Morgan
cf291d3226 Add experimental config option for mscs 2244,2174 2022-03-06 10:06:38 +00:00
3 changed files with 17 additions and 0 deletions

View File

@@ -81,6 +81,9 @@ class RoomVersion:
msc2716_historical: bool
# MSC2716: Adds support for redacting "insertion", "chunk", and "marker" events
msc2716_redactions: bool
# MSC2174: Move the "redacts" key from the top-level of the event to the content
# MSC2244: Adds support for a "redacts" array of event IDs in an event's content
msc2174_msc2244_redactions: bool
class RoomVersions:

View File

@@ -61,3 +61,8 @@ class ExperimentalConfig(Config):
self.msc2409_to_device_messages_enabled: bool = experimental.get(
"msc2409_to_device_messages_enabled", False
)
# MSC2174 (Move the 'redacts' key) and MSC2244 (Mass Redactions)
self.msc2174_msc2244_enabled: bool = experimental.get(
"msc2174_msc2244_enabled", False
)

View File

@@ -875,6 +875,9 @@ class RoomRedactEventRestServlet(TransactionRestServlet):
self.event_creation_handler = hs.get_event_creation_handler()
self.auth = hs.get_auth()
# MSC2244 (mass redactions) and MSC2174 (move 'redacts' into event content)
self._msc2174_msc2244_enabled = hs.config.experimental.msc2174_msc2244_enabled
def register(self, http_server: HttpServer) -> None:
PATTERNS = "/rooms/(?P<room_id>[^/]*)/redact/(?P<event_id>[^/]*)"
register_txn_path(self, PATTERNS, http_server)
@@ -889,6 +892,12 @@ class RoomRedactEventRestServlet(TransactionRestServlet):
requester = await self.auth.get_user_by_req(request)
content = parse_json_object_from_request(request)
if self._msc2174_msc2244_enabled:
# Include a "redacts" array in the *event content* that contains the
# event ID to redact in accordance with MSC2244.
# The top-level "redacts" key is kept for backwards compatibility.
content["redacts"] = [event_id]
try:
(
event,