From 2f413af0a8e9e90b8a7dc971e83f2d4435fb8d9a Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Tue, 2 May 2023 17:00:05 +0200 Subject: [PATCH] ffi: Correct timestamp value and remove is_read flag The timestamp value of the Notification was not reliable since it was the timestamp in which it was generated internally, not the timestamp of when the event was sent, now we instead expose the `origin_server_ts` of the TimelineEvent. `is_read` is also very unreliable, so it's just removed for now. --- bindings/matrix-sdk-ffi/src/api.udl | 2 -- bindings/matrix-sdk-ffi/src/event.rs | 4 ++++ bindings/matrix-sdk-ffi/src/notification_service.rs | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/api.udl b/bindings/matrix-sdk-ffi/src/api.udl index 38e8fdaa7..76e2de280 100644 --- a/bindings/matrix-sdk-ffi/src/api.udl +++ b/bindings/matrix-sdk-ffi/src/api.udl @@ -22,8 +22,6 @@ dictionary NotificationItem { boolean is_noisy; boolean is_direct; boolean is_encrypted; - boolean is_read; - u64 timestamp; }; interface TimelineEvent {}; diff --git a/bindings/matrix-sdk-ffi/src/event.rs b/bindings/matrix-sdk-ffi/src/event.rs index 0c30d7780..04fac27b5 100644 --- a/bindings/matrix-sdk-ffi/src/event.rs +++ b/bindings/matrix-sdk-ffi/src/event.rs @@ -19,6 +19,10 @@ impl TimelineEvent { self.0.sender().to_string() } + pub fn timestamp(&self) -> u64 { + self.0.origin_server_ts().0.into() + } + pub fn event_type(&self) -> Result { let event_type = match &self.0 { AnySyncTimelineEvent::MessageLike(event) => { diff --git a/bindings/matrix-sdk-ffi/src/notification_service.rs b/bindings/matrix-sdk-ffi/src/notification_service.rs index 462968682..16cf23fbf 100644 --- a/bindings/matrix-sdk-ffi/src/notification_service.rs +++ b/bindings/matrix-sdk-ffi/src/notification_service.rs @@ -18,9 +18,6 @@ pub struct NotificationItem { pub is_noisy: bool, pub is_direct: bool, pub is_encrypted: bool, - pub is_read: bool, - - pub timestamp: u64, } impl NotificationItem { @@ -48,8 +45,6 @@ impl NotificationItem { is_noisy, is_direct: room.is_direct().await?, is_encrypted: room.is_encrypted().await?, - is_read: notification.read, - timestamp: notification.ts.0.into(), }; Ok(item) }