Skip to content

Commit 17df3f8

Browse files
authored
feat(ffi): expose join_rules in OtherState::RoomJoinRules (#5863)
Expose the room join rules in the `OtherState::RoomJoinRules` event for the FFI timeline. It reuses the existing `JoinRules` type from the client module and converts the event content accordingly. This allows clients to inspect the room’s current join rule directly from the event. Like `m.federate`, this field was previously unavailable in the FFI variant of the SDK. --------- Signed-off-by: JoFrost <[email protected]>
1 parent 4fbc83a commit 17df3f8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ All notable changes to this project will be documented in this file.
8181
- Add new API to decline calls ([MSC4310](https://github.com/matrix-org/matrix-spec-proposals/pull/4310)): `Room::decline_call` and `Room::subscribe_to_call_decline_events`
8282
([#5614](https://github.com/matrix-org/matrix-rust-sdk/pull/5614))
8383
- Expose `m.federate` in `OtherState::RoomCreate` and `history_visibility` in `OtherState::RoomHistoryVisibility`, allowing clients to know whether a room federates and how its history is shared in the appropriate timeline events.
84+
- Expose `join_rule` in `OtherState::RoomJoinRules`, allowing clients to know the join rules of a room from the appropriate timeline events.
8485

8586
### Changes
8687

bindings/matrix-sdk-ffi/src/timeline/content.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use ruma::events::{
2020
room::history_visibility::HistoryVisibility as RumaHistoryVisibility, FullStateEventContent,
2121
};
2222

23-
use crate::{timeline::msg_like::MsgLikeContent, utils::Timestamp};
23+
use crate::{client::JoinRule, timeline::msg_like::MsgLikeContent, utils::Timestamp};
2424

2525
impl From<matrix_sdk_ui::timeline::TimelineItemContent> for TimelineItemContent {
2626
fn from(value: matrix_sdk_ui::timeline::TimelineItemContent) -> Self {
@@ -254,7 +254,7 @@ pub enum OtherState {
254254
RoomEncryption,
255255
RoomGuestAccess,
256256
RoomHistoryVisibility { history_visibility: Option<HistoryVisibility> },
257-
RoomJoinRules,
257+
RoomJoinRules { join_rule: Option<JoinRule> },
258258
RoomName { name: Option<String> },
259259
RoomPinnedEvents { change: RoomPinnedEventsChange },
260260
RoomPowerLevels { users: HashMap<String, i64>, previous: Option<HashMap<String, i64>> },
@@ -305,7 +305,21 @@ impl From<&matrix_sdk_ui::timeline::AnyOtherFullStateEventContent> for OtherStat
305305
};
306306
Self::RoomHistoryVisibility { history_visibility }
307307
}
308-
Content::RoomJoinRules(_) => Self::RoomJoinRules,
308+
Content::RoomJoinRules(c) => {
309+
let join_rule = match c {
310+
FullContent::Original { content, .. } => {
311+
match content.join_rule.clone().try_into() {
312+
Ok(jr) => Some(jr),
313+
Err(err) => {
314+
tracing::error!("Failed to convert join rule: {}", err);
315+
None
316+
}
317+
}
318+
}
319+
FullContent::Redacted(_) => None,
320+
};
321+
Self::RoomJoinRules { join_rule }
322+
}
309323
Content::RoomName(c) => {
310324
let name = match c {
311325
FullContent::Original { content, .. } => Some(content.name.clone()),

0 commit comments

Comments
 (0)