feat(ffi): expose ffi::RoomInfo::tombstone

This replaces `ffi::RoomInfo::is_tombstoned`, including the needed extra info for the migration UI.
This commit is contained in:
Jorge Martín
2025-05-13 13:12:29 +02:00
committed by Jorge Martin Espinosa
parent 7d992d1af8
commit 44e103c0e3
2 changed files with 21 additions and 2 deletions

View File

@@ -13,6 +13,9 @@ Breaking changes:
allows a foreign language to read file contents natively and then pass those contents to
the foreign function when uploading a file through the `Timeline`.
([#4948](https://github.com/matrix-org/matrix-rust-sdk/pull/4948))
- `RoomInfo` replaces its field `is_tombstoned: bool` with `tombstone: Option<RoomTombstoneInfo>`,
containing the data needed to implement the room migration UI, a message and the replacement room id.
([#5027](https://github.com/matrix-org/matrix-rust-sdk/pull/5027))
Additions:

View File

@@ -1,6 +1,7 @@
use std::collections::HashMap;
use matrix_sdk::{EncryptionState, RoomState};
use ruma::events::room::tombstone::RoomTombstoneEventContent;
use tracing::warn;
use crate::{
@@ -26,7 +27,8 @@ pub struct RoomInfo {
is_direct: bool,
is_public: bool,
is_space: bool,
is_tombstoned: bool,
/// If present, it means the room has been archived/upgraded.
tombstone: Option<RoomTombstoneInfo>,
is_favourite: bool,
canonical_alias: Option<String>,
alternative_aliases: Vec<String>,
@@ -94,7 +96,7 @@ impl RoomInfo {
is_direct: room.is_direct().await?,
is_public: room.is_public(),
is_space: room.is_space(),
is_tombstoned: room.is_tombstoned(),
tombstone: room.tombstone().map(Into::into),
is_favourite: room.is_favourite(),
canonical_alias: room.canonical_alias().map(Into::into),
alternative_aliases: room.alt_aliases().into_iter().map(Into::into).collect(),
@@ -137,3 +139,17 @@ impl RoomInfo {
})
}
}
/// Contains the `m.room.tombstone` state of the room, with a message about the
/// room upgrade and the id of the newly created room to replace this one.
#[derive(uniffi::Record)]
pub struct RoomTombstoneInfo {
body: String,
replacement_room_id: String,
}
impl From<ruma::events::room::tombstone::RoomTombstoneEventContent> for RoomTombstoneInfo {
fn from(value: RoomTombstoneEventContent) -> Self {
Self { body: value.body, replacement_room_id: value.replacement_room.to_string() }
}
}