From 9d0f23c8a78924df3d431d5e01ba0982203e4807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Thu, 17 Aug 2023 17:24:32 +0200 Subject: [PATCH] canonical-json: Apply redaction rules of MSC3821 --- crates/ruma-common/CHANGELOG.md | 12 +++++++----- crates/ruma-common/src/canonical_json.rs | 11 ++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/ruma-common/CHANGELOG.md b/crates/ruma-common/CHANGELOG.md index 291c316e..0b4dbfb7 100644 --- a/crates/ruma-common/CHANGELOG.md +++ b/crates/ruma-common/CHANGELOG.md @@ -33,11 +33,6 @@ Breaking changes: in room version 11, according to MSC2175 / MSC3820 / Matrix 1.8 - `RoomCreateEventContent::new()` was renamed to `new_v1()` - `RedactedRoomCreateEventContent` is now a typedef over `RoomCreateEventContent` -- Add preserved fields to match the new redaction algorithm in room version 11, according to - MSC2176 / MSC3821 / MSC3820 / Matrix 1.8, for the following types: - - `RedactedRoomRedactionEventContent`, - - `RedactedRoomPowerLevelsEventContent`, - - `RedactedRoomMemberEventContent` - `RoomMessageEventContent::make_reply_to()` and `make_for_thread()` have an extra parameter to support the recommended behavior for intentional mentions in replies according to Matrix 1.7 - In Markdown, soft line breaks are transformed into hard line breaks when compiled into HTML. @@ -75,6 +70,13 @@ Improvements: - Make the generated and stripped plain text reply fallback behavior more compatible with most of the Matrix ecosystem. - Add support for intentional mentions according to MSC3952 / Matrix 1.7 +- Add support for room version 11 according to MSC3820 + - Adapt the redaction algorithm in `canonical_json` + - Add preserved fields to match the new redaction algorithm, according to + MSC2176 / MSC3821, for the following types: + - `RedactedRoomRedactionEventContent`, + - `RedactedRoomPowerLevelsEventContent`, + - `RedactedRoomMemberEventContent` # 0.11.3 diff --git a/crates/ruma-common/src/canonical_json.rs b/crates/ruma-common/src/canonical_json.rs index 9bfeb17b..ad23842d 100644 --- a/crates/ruma-common/src/canonical_json.rs +++ b/crates/ruma-common/src/canonical_json.rs @@ -362,6 +362,14 @@ static ROOM_MEMBER_V1: AllowedKeys = AllowedKeys::some(&["membership"]); /// Allowed keys in `m.room.member`'s content according to room version 9. static ROOM_MEMBER_V9: AllowedKeys = AllowedKeys::some(&["membership", "join_authorised_via_users_server"]); +/// Allowed keys in `m.room.member`'s content according to room version 11. +static ROOM_MEMBER_V11: AllowedKeys = AllowedKeys::some_nested( + &["membership", "join_authorised_via_users_server"], + &[("third_party_invite", &ROOM_MEMBER_THIRD_PARTY_INVITE_V11)], +); +/// Allowed keys in the `third_party_invite` field of `m.room.member`'s content according to room +/// version 11. +static ROOM_MEMBER_THIRD_PARTY_INVITE_V11: AllowedKeys = AllowedKeys::some(&["signed"]); /// Allowed keys in `m.room.create`'s content according to room version 1. static ROOM_CREATE_V1: AllowedKeys = AllowedKeys::some(&["creator"]); @@ -420,7 +428,8 @@ fn allowed_content_keys_for(event_type: &str, version: &RoomVersionId) -> &'stat | RoomVersionId::V6 | RoomVersionId::V7 | RoomVersionId::V8 => &ROOM_MEMBER_V1, - _ => &ROOM_MEMBER_V9, + RoomVersionId::V9 | RoomVersionId::V10 => &ROOM_MEMBER_V9, + _ => &ROOM_MEMBER_V11, }, "m.room.create" => match version { RoomVersionId::V1