From c707e1f17eb28f20bd3893c443550fac8170bcde Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:29:06 +0100 Subject: [PATCH] feat(bindings): expose a function to send private read receipts (#2906) --- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index b4bde590e..ede068331 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -25,7 +25,6 @@ use matrix_sdk::attachment::{ use matrix_sdk_ui::timeline::{BackPaginationStatus, EventItemOrigin, Profile, TimelineDetails}; use mime::Mime; use ruma::{ - api::client::receipt::create_receipt::v3::ReceiptType, events::{ location::{AssetType as RumaAssetType, LocationContent, ZoomLevel}, poll::{ @@ -182,12 +181,16 @@ impl Timeline { RUNTIME.block_on(async { Ok(self.inner.paginate_backwards(opts.into()).await?) }) } - pub fn send_read_receipt(&self, event_id: String) -> Result<(), ClientError> { + pub fn send_read_receipt( + &self, + receipt_type: ReceiptType, + event_id: String, + ) -> Result<(), ClientError> { let event_id = EventId::parse(event_id)?; RUNTIME.block_on(async { self.inner - .send_single_receipt(ReceiptType::Read, ReceiptThread::Unthreaded, event_id) + .send_single_receipt(receipt_type.into(), ReceiptThread::Unthreaded, event_id) .await?; Ok(()) }) @@ -975,3 +978,21 @@ pub enum VirtualTimelineItem { /// The user's own read marker. ReadMarker, } + +/// A [`TimelineItem`](super::TimelineItem) that doesn't correspond to an event. +#[derive(uniffi::Enum)] +pub enum ReceiptType { + Read, + ReadPrivate, + FullyRead, +} + +impl From for ruma::api::client::receipt::create_receipt::v3::ReceiptType { + fn from(value: ReceiptType) -> Self { + match value { + ReceiptType::Read => Self::Read, + ReceiptType::ReadPrivate => Self::Read, + ReceiptType::FullyRead => Self::FullyRead, + } + } +}