diff --git a/bindings/matrix-sdk-ffi/CHANGELOG.md b/bindings/matrix-sdk-ffi/CHANGELOG.md index 331d38294..fcfcb57c0 100644 --- a/bindings/matrix-sdk-ffi/CHANGELOG.md +++ b/bindings/matrix-sdk-ffi/CHANGELOG.md @@ -8,17 +8,17 @@ All notable changes to this project will be documented in this file. ### Bug Fixes -- `omit_checksums` option is now enabled for the Kotlin bindings in all FFI-exporting crates. +- `omit_checksums` option is now enabled for the Kotlin bindings in all FFI-exporting crates. We enabled them because with JNA direct mapping enabled they result in invalid checks in - ARM 32bit devices, preventing the SDK from working altogether (see -[this issue](https://github.com/mozilla/uniffi-rs/issues/2740)). -([#6069](https://github.com/matrix-org/matrix-rust-sdk/pull/6069), -[#6112](https://github.com/matrix-org/matrix-rust-sdk/pull/6112), + ARM 32bit devices, preventing the SDK from working altogether (see +[this issue](https://github.com/mozilla/uniffi-rs/issues/2740)). +([#6069](https://github.com/matrix-org/matrix-rust-sdk/pull/6069), +[#6112](https://github.com/matrix-org/matrix-rust-sdk/pull/6112), [#6115](https://github.com/matrix-org/matrix-rust-sdk/pull/6115), [#6116](https://github.com/matrix-org/matrix-rust-sdk/pull/6116)). -- `Client::create_room` now uses `RoomPowerLevelsContentOverride` under the hood instead of - `RoomPowerLevelsEventContent` to be able to explicitly set values which would previously be - ignored if they matched the default power level values specified by the spec: these may not be +- `Client::create_room` now uses `RoomPowerLevelsContentOverride` under the hood instead of + `RoomPowerLevelsEventContent` to be able to explicitly set values which would previously be + ignored if they matched the default power level values specified by the spec: these may not be the same in the homeserver and result in rooms with incorrect power levels being created. ([#6034](https://github.com/matrix-org/matrix-rust-sdk/pull/6034)) - Fix the `is_last_admin` check in `LeaveSpaceRoom` since it was not @@ -64,23 +64,25 @@ All notable changes to this project will be documented in this file. `Room::new_latest_event` overwrites the `Room::latest_event` method. See the documentation of `matrix_sdk::latest_event` to learn about the new API. [#5624](https://github.com/matrix-org/matrix-rust-sdk/pull/5624/) -- Created `RoomPowerLevels::events` function which returns a `HashMap` with all the power +- Created `RoomPowerLevels::events` function which returns a `HashMap` with all the power levels per event type. ([#5937](https://github.com/matrix-org/matrix-rust-sdk/pull/5937)) - Expose `EventTimelineItem::forwarder` and `forwarder_profile`, which, if present, provide the ID and profile of the user who forwarded the keys used to decrypt the event as part of an [MSC4268](https://github.com/matrix-org/matrix-spec-proposals/pull/4268) key bundle. ([#6000](https://github.com/matrix-org/matrix-rust-sdk/pull/6000)) - Add `NonFavorite` filter to the Room List API. ([#5991](https://github.com/matrix-org/matrix-rust-sdk/pull/5991)) - +- Add `NotificationItem::raw_event` to get the raw event content of the event that triggered the notification, which can be useful for debugging and to support clients that want to implement custom handling for certain notifications. + (TBD) + ### Refactor - [**breaking**] Refactored `is_last_admin` to `is_last_owner` the check will now account also for v12 rooms, where creators and users with PL 150 matter. ([#6036](https://github.com/matrix-org/matrix-rust-sdk/pull/6036)) -- [**breaking**] The existing `TimelineEventType` was renamed to `TimelineEventContent`, because it contained the - actual contents of the event. Then, we created a new `TimelineEventType` enum that actually contains *just* the +- [**breaking**] The existing `TimelineEventType` was renamed to `TimelineEventContent`, because it contained the + actual contents of the event. Then, we created a new `TimelineEventType` enum that actually contains *just* the event type. ([#5937](https://github.com/matrix-org/matrix-rust-sdk/pull/5937)) -- [**breaking**] The function `TimelineEvent::event_type` is now `TimelineEvent::content`. +- [**breaking**] The function `TimelineEvent::event_type` is now `TimelineEvent::content`. ([#5937](https://github.com/matrix-org/matrix-rust-sdk/pull/5937)) - [**breaking**] The `SpaceService` will no longer auto-subscribe to required client events when invoking the `subscribe_to_joined_spaces` but instead do it diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 697764342..d7b41122c 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -905,46 +905,50 @@ impl Client { .collect(); // Convert SDK event to FFI type - let (sender, event, thread_id) = match notification.event { - RawAnySyncOrStrippedTimelineEvent::Sync(raw) => match raw.deserialize() { - Ok(deserialized) => { - let sender = deserialized.sender().to_owned(); - let thread_id = match &deserialized { - AnySyncTimelineEvent::MessageLike(event) => { - match event.original_content() { - Some(AnyMessageLikeEventContent::RoomMessage( - content, - )) => match content.relates_to { - Some(Relation::Thread(thread)) => { - Some(thread.event_id.to_string()) - } + let (sender, event, thread_id, raw_event) = match notification.event { + RawAnySyncOrStrippedTimelineEvent::Sync(raw) => { + let raw_event = raw.json().get().to_owned(); + match raw.deserialize() { + Ok(deserialized) => { + let sender = deserialized.sender().to_owned(); + let thread_id = match &deserialized { + AnySyncTimelineEvent::MessageLike(event) => { + match event.original_content() { + Some(AnyMessageLikeEventContent::RoomMessage( + content, + )) => match content.relates_to { + Some(Relation::Thread(thread)) => { + Some(thread.event_id.to_string()) + } + _ => None, + }, _ => None, - }, - _ => None, + } } - } - _ => None, - }; - let event = NotificationEvent::Timeline { - event: Arc::new(crate::event::TimelineEvent(Box::new( - deserialized, - ))), - }; - (sender, event, thread_id) + _ => None, + }; + let event = NotificationEvent::Timeline { + event: Arc::new(crate::event::TimelineEvent(Box::new( + deserialized, + ))), + }; + (sender, event, thread_id, raw_event) + } + Err(err) => { + tracing::warn!("Failed to deserialize timeline event: {err}"); + return; + } } - Err(err) => { - tracing::warn!("Failed to deserialize timeline event: {err}"); - return; - } - }, + } RawAnySyncOrStrippedTimelineEvent::Stripped(raw) => { + let raw_event = raw.json().get().to_owned(); match raw.deserialize() { Ok(deserialized) => { let sender = deserialized.sender().to_owned(); let event = NotificationEvent::Invite { sender: sender.to_string() }; let thread_id = None; - (sender, event, thread_id) + (sender, event, thread_id, raw_event) } Err(err) => { tracing::warn!( @@ -1007,6 +1011,7 @@ impl Client { listener.on_notification( NotificationItem { event, + raw_event, sender_info, room_info, is_noisy: Some(is_noisy), diff --git a/bindings/matrix-sdk-ffi/src/notification.rs b/bindings/matrix-sdk-ffi/src/notification.rs index 0b3577189..207b7bffa 100644 --- a/bindings/matrix-sdk-ffi/src/notification.rs +++ b/bindings/matrix-sdk-ffi/src/notification.rs @@ -3,6 +3,7 @@ use std::{collections::HashMap, sync::Arc}; use matrix_sdk_ui::notification_client::{ NotificationClient as SdkNotificationClient, NotificationEvent as SdkNotificationEvent, NotificationItem as SdkNotificationItem, NotificationStatus as SdkNotificationStatus, + RawNotificationEvent as SdkRawNotificationEvent, }; use ruma::{EventId, OwnedEventId, OwnedRoomId, RoomId}; @@ -43,6 +44,9 @@ pub struct NotificationRoomInfo { pub struct NotificationItem { pub event: NotificationEvent, + /// The raw JSON of the underlying event. + pub raw_event: String, + pub sender_info: NotificationSenderInfo, pub room_info: NotificationRoomInfo, @@ -67,8 +71,15 @@ impl NotificationItem { NotificationEvent::Invite { sender: event.sender.to_string() } } }; + + let raw_event = match &item.raw_event { + SdkRawNotificationEvent::Timeline(raw) => raw.json().get().to_owned(), + SdkRawNotificationEvent::Invite(raw) => raw.json().get().to_owned(), + }; + Self { event, + raw_event, sender_info: NotificationSenderInfo { display_name: item.sender_display_name, avatar_url: item.sender_avatar_url,