canonical-json: Apply redaction rules of MSC3821

This commit is contained in:
Kévin Commaille 2023-08-17 17:24:32 +02:00 committed by Kévin Commaille
parent 5d68ba3ff4
commit 9d0f23c8a7
2 changed files with 17 additions and 6 deletions

View File

@ -33,11 +33,6 @@ Breaking changes:
in room version 11, according to MSC2175 / MSC3820 / Matrix 1.8 in room version 11, according to MSC2175 / MSC3820 / Matrix 1.8
- `RoomCreateEventContent::new()` was renamed to `new_v1()` - `RoomCreateEventContent::new()` was renamed to `new_v1()`
- `RedactedRoomCreateEventContent` is now a typedef over `RoomCreateEventContent` - `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 - `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 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. - 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 - Make the generated and stripped plain text reply fallback behavior more compatible with most
of the Matrix ecosystem. of the Matrix ecosystem.
- Add support for intentional mentions according to MSC3952 / Matrix 1.7 - 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 # 0.11.3

View File

@ -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. /// Allowed keys in `m.room.member`'s content according to room version 9.
static ROOM_MEMBER_V9: AllowedKeys = static ROOM_MEMBER_V9: AllowedKeys =
AllowedKeys::some(&["membership", "join_authorised_via_users_server"]); 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. /// Allowed keys in `m.room.create`'s content according to room version 1.
static ROOM_CREATE_V1: AllowedKeys = AllowedKeys::some(&["creator"]); 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::V6
| RoomVersionId::V7 | RoomVersionId::V7
| RoomVersionId::V8 => &ROOM_MEMBER_V1, | RoomVersionId::V8 => &ROOM_MEMBER_V1,
_ => &ROOM_MEMBER_V9, RoomVersionId::V9 | RoomVersionId::V10 => &ROOM_MEMBER_V9,
_ => &ROOM_MEMBER_V11,
}, },
"m.room.create" => match version { "m.room.create" => match version {
RoomVersionId::V1 RoomVersionId::V1