Skip to content

Commit 44e103c

Browse files
committed
feat(ffi): expose ffi::RoomInfo::tombstone
This replaces `ffi::RoomInfo::is_tombstoned`, including the needed extra info for the migration UI.
1 parent 7d992d1 commit 44e103c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Breaking changes:
1313
allows a foreign language to read file contents natively and then pass those contents to
1414
the foreign function when uploading a file through the `Timeline`.
1515
([#4948](https://github.com/matrix-org/matrix-rust-sdk/pull/4948))
16+
- `RoomInfo` replaces its field `is_tombstoned: bool` with `tombstone: Option<RoomTombstoneInfo>`,
17+
containing the data needed to implement the room migration UI, a message and the replacement room id.
18+
([#5027](https://github.com/matrix-org/matrix-rust-sdk/pull/5027))
1619

1720
Additions:
1821

bindings/matrix-sdk-ffi/src/room_info.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashMap;
22

33
use matrix_sdk::{EncryptionState, RoomState};
4+
use ruma::events::room::tombstone::RoomTombstoneEventContent;
45
use tracing::warn;
56

67
use crate::{
@@ -26,7 +27,8 @@ pub struct RoomInfo {
2627
is_direct: bool,
2728
is_public: bool,
2829
is_space: bool,
29-
is_tombstoned: bool,
30+
/// If present, it means the room has been archived/upgraded.
31+
tombstone: Option<RoomTombstoneInfo>,
3032
is_favourite: bool,
3133
canonical_alias: Option<String>,
3234
alternative_aliases: Vec<String>,
@@ -94,7 +96,7 @@ impl RoomInfo {
9496
is_direct: room.is_direct().await?,
9597
is_public: room.is_public(),
9698
is_space: room.is_space(),
97-
is_tombstoned: room.is_tombstoned(),
99+
tombstone: room.tombstone().map(Into::into),
98100
is_favourite: room.is_favourite(),
99101
canonical_alias: room.canonical_alias().map(Into::into),
100102
alternative_aliases: room.alt_aliases().into_iter().map(Into::into).collect(),
@@ -137,3 +139,17 @@ impl RoomInfo {
137139
})
138140
}
139141
}
142+
143+
/// Contains the `m.room.tombstone` state of the room, with a message about the
144+
/// room upgrade and the id of the newly created room to replace this one.
145+
#[derive(uniffi::Record)]
146+
pub struct RoomTombstoneInfo {
147+
body: String,
148+
replacement_room_id: String,
149+
}
150+
151+
impl From<ruma::events::room::tombstone::RoomTombstoneEventContent> for RoomTombstoneInfo {
152+
fn from(value: RoomTombstoneEventContent) -> Self {
153+
Self { body: value.body, replacement_room_id: value.replacement_room.to_string() }
154+
}
155+
}

0 commit comments

Comments
 (0)