From 44e103c0e33e395d48c5d5ea68ca41557eb6940b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 13 May 2025 13:12:29 +0200 Subject: [PATCH] feat(ffi): expose `ffi::RoomInfo::tombstone` This replaces `ffi::RoomInfo::is_tombstoned`, including the needed extra info for the migration UI. --- bindings/matrix-sdk-ffi/CHANGELOG.md | 3 +++ bindings/matrix-sdk-ffi/src/room_info.rs | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bindings/matrix-sdk-ffi/CHANGELOG.md b/bindings/matrix-sdk-ffi/CHANGELOG.md index 9ff649130..8a41d0769 100644 --- a/bindings/matrix-sdk-ffi/CHANGELOG.md +++ b/bindings/matrix-sdk-ffi/CHANGELOG.md @@ -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`, + 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: diff --git a/bindings/matrix-sdk-ffi/src/room_info.rs b/bindings/matrix-sdk-ffi/src/room_info.rs index 894f192ff..95843020d 100644 --- a/bindings/matrix-sdk-ffi/src/room_info.rs +++ b/bindings/matrix-sdk-ffi/src/room_info.rs @@ -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, is_favourite: bool, canonical_alias: Option, alternative_aliases: Vec, @@ -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 for RoomTombstoneInfo { + fn from(value: RoomTombstoneEventContent) -> Self { + Self { body: value.body, replacement_room_id: value.replacement_room.to_string() } + } +}