Skip to content

Commit

Permalink
canonical-json: Apply redaction rules of MSC3821
Browse files Browse the repository at this point in the history
  • Loading branch information
zecakeh committed Aug 29, 2023
1 parent 5d68ba3 commit 9d0f23c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 7 additions & 5 deletions crates/ruma-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion crates/ruma-common/src/canonical_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9d0f23c

Please sign in to comment.