Skip to content
Merged
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
2 changes: 2 additions & 0 deletions bindings/matrix-sdk-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.

### Breaking changes

- Expose the power level required to modify `m.space.child` on
`room::power_levels::RoomPowerLevelsValues`.
- Rename `Client::login_with_qr_code` to `Client::new_login_with_qr_code_handler`.
([#5836](https://github.com/matrix-org/matrix-rust-sdk/pull/5836))
- Add the `sqlite` feature, along with the `indexeddb` feature, to enable either
Expand Down
3 changes: 3 additions & 0 deletions bindings/matrix-sdk-ffi/src/room/power_levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ pub struct RoomPowerLevelsValues {
pub room_avatar: i64,
/// The level required to change the room's topic.
pub room_topic: i64,
/// The level required to change the space's children.
pub space_child: i64,
}

impl From<RumaPowerLevels> for RoomPowerLevelsValues {
Expand All @@ -228,6 +230,7 @@ impl From<RumaPowerLevels> for RoomPowerLevelsValues {
room_name: state_event_level_for(&value, &TimelineEventType::RoomName),
room_avatar: state_event_level_for(&value, &TimelineEventType::RoomAvatar),
room_topic: state_event_level_for(&value, &TimelineEventType::RoomTopic),
space_child: state_event_level_for(&value, &TimelineEventType::SpaceChild),
}
}
}
3 changes: 3 additions & 0 deletions crates/matrix-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.

### Features

- Expose the power level required to modify `m.space.child` on
`room::power_levels::RoomPowerLevelChanges`.
([#5857](https://github.com/matrix-org/matrix-rust-sdk/pull/5857))
- Add the `Client::server_versions_cached()` method.
([#5853](https://github.com/matrix-org/matrix-rust-sdk/pull/5853))
- Extend `authentication::oauth::OAuth::grant_login_with_qr_code` to support granting
Expand Down
18 changes: 18 additions & 0 deletions crates/matrix-sdk/src/room/power_levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub struct RoomPowerLevelChanges {
/// The level required to change the room's topic.
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
pub room_topic: Option<i64>,
/// The level required to change the space's children.
#[cfg_attr(feature = "uniffi", uniffi(default = None))]
pub space_child: Option<i64>,
}

impl RoomPowerLevelChanges {
Expand All @@ -70,6 +73,7 @@ impl RoomPowerLevelChanges {
room_name: None,
room_avatar: None,
room_topic: None,
space_child: None,
}
}
}
Expand Down Expand Up @@ -105,6 +109,11 @@ impl From<RoomPowerLevels> for RoomPowerLevelChanges {
.get(&StateEventType::RoomTopic.into())
.map(|v| (*v).into())
.or(Some(value.state_default.into())),
space_child: value
.events
.get(&StateEventType::SpaceChild.into())
.map(|v| (*v).into())
.or(Some(value.state_default.into())),
}
}
}
Expand Down Expand Up @@ -150,6 +159,9 @@ impl RoomPowerLevelsExt for RoomPowerLevels {
if let Some(room_topic) = settings.room_topic {
self.events.insert(StateEventType::RoomTopic.into(), room_topic.try_into()?);
}
if let Some(space_child) = settings.space_child {
self.events.insert(StateEventType::SpaceChild.into(), space_child.try_into()?);
}

Ok(())
}
Expand Down Expand Up @@ -223,6 +235,7 @@ mod tests {
room_name: None,
room_avatar: None,
room_topic: None,
space_child: None,
};

// When applying the settings to the power levels.
Expand Down Expand Up @@ -259,6 +272,7 @@ mod tests {
room_name: Some(new_level.into()),
room_avatar: Some(new_level.into()),
room_topic: Some(new_level.into()),
space_child: Some(new_level.into()),
};

// When applying the settings to the power levels.
Expand All @@ -272,6 +286,7 @@ mod tests {
(StateEventType::RoomName.into(), new_level),
(StateEventType::RoomAvatar.into(), new_level),
(StateEventType::RoomTopic.into(), new_level),
(StateEventType::SpaceChild.into(), new_level),
])
);
// And the rest should remain unchanged.
Expand All @@ -294,6 +309,7 @@ mod tests {
(StateEventType::RoomName.into(), original_level),
(StateEventType::RoomAvatar.into(), original_level),
(StateEventType::RoomTopic.into(), original_level),
(StateEventType::SpaceChild.into(), original_level),
]);

let settings = RoomPowerLevelChanges {
Expand All @@ -307,6 +323,7 @@ mod tests {
room_name: Some(power_levels.state_default.into()),
room_avatar: None,
room_topic: None,
space_child: None,
};

// When applying the settings to the power levels.
Expand All @@ -321,6 +338,7 @@ mod tests {
(StateEventType::RoomName.into(), power_levels.state_default),
(StateEventType::RoomAvatar.into(), original_level),
(StateEventType::RoomTopic.into(), original_level),
(StateEventType::SpaceChild.into(), original_level),
])
);
// And the rest should remain unchanged.
Expand Down
Loading