From 514929ca2a43d4a7170afc69a72b67f350aabe97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Fri, 8 Nov 2024 11:57:03 +0100 Subject: [PATCH] feat(ffi): add `reason` field to `TimelineItemContent::RoomMembership` --- .../matrix-sdk-ffi/src/timeline/content.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/content.rs b/bindings/matrix-sdk-ffi/src/timeline/content.rs index e39f2c0798d..0b01ef5005b 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/content.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/content.rs @@ -16,7 +16,7 @@ use std::{collections::HashMap, sync::Arc}; use matrix_sdk::{crypto::types::events::UtdCause, room::power_levels::power_level_user_changes}; use matrix_sdk_ui::timeline::{PollResult, RoomPinnedEventsChange, TimelineDetails}; -use ruma::events::room::MediaSource; +use ruma::events::{room::MediaSource, FullStateEventContent}; use super::ProfileDetails; use crate::ruma::{ImageInfo, Mentions, MessageType, PollKind}; @@ -49,11 +49,18 @@ impl From for TimelineItemContent TimelineItemContent::UnableToDecrypt { msg: EncryptedMessage::new(&msg) } } - Content::MembershipChange(membership) => TimelineItemContent::RoomMembership { - user_id: membership.user_id().to_string(), - user_display_name: membership.display_name(), - change: membership.change().map(Into::into), - }, + Content::MembershipChange(membership) => { + let reason = match membership.content() { + FullStateEventContent::Original { content, .. } => content.reason.clone(), + _ => None, + }; + TimelineItemContent::RoomMembership { + user_id: membership.user_id().to_string(), + user_display_name: membership.display_name(), + change: membership.change().map(Into::into), + reason, + } + } Content::ProfileChange(profile) => { let (display_name, prev_display_name) = profile @@ -161,6 +168,7 @@ pub enum TimelineItemContent { user_id: String, user_display_name: Option, change: Option, + reason: Option, }, ProfileChange { display_name: Option,