From eaec03142bf522c37691f6efb53b752bf3e6fbf8 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 9 Oct 2020 14:17:41 +0300 Subject: [PATCH] Use get_summarytext() for quotes Co-Authored-By: Hocuri --- deltachat-ffi/src/lib.rs | 13 ++++++++----- src/message.rs | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index f1b860cac..52d779baa 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2984,11 +2984,14 @@ pub unsafe extern "C" fn dc_msg_set_quote(msg: *mut dc_msg_t, quote: *const dc_m let ffi_msg = &mut *msg; let ffi_quote = &*quote; - ffi_msg - .message - .set_quote(&ffi_quote.message) - .log_err(&*ffi_msg.context, "failed to set quote") - .ok(); + block_on(async move { + ffi_msg + .message + .set_quote(&*ffi_msg.context, &ffi_quote.message) + .await + .log_err(&*ffi_msg.context, "failed to set quote") + .ok(); + }); } #[no_mangle] diff --git a/src/message.rs b/src/message.rs index fa7be20b6..dbefd58ad 100644 --- a/src/message.rs +++ b/src/message.rs @@ -749,7 +749,7 @@ impl Message { /// /// The message itself is not required to exist in the database, /// it may even be deleted from the database by the time the message is prepared. - pub fn set_quote(&mut self, quote: &Message) -> Result<(), Error> { + pub async fn set_quote(&mut self, context: &Context, quote: &Message) -> Result<(), Error> { ensure!( !quote.rfc724_mid.is_empty(), "Message without Message-Id cannot be quoted" @@ -765,7 +765,7 @@ impl Message { } self.param - .set(Param::Quote, quote.get_text().unwrap_or_default()); + .set(Param::Quote, quote.get_summarytext(context, 500).await); Ok(()) } @@ -2090,7 +2090,7 @@ mod tests { assert!(!msg.rfc724_mid.is_empty()); let mut msg2 = Message::new(Viewtype::Text); - msg2.set_quote(&msg).expect("can't set quote"); + msg2.set_quote(ctx, &msg).await.expect("can't set quote"); assert!(msg2.quoted_text() == msg.get_text()); let quoted_msg = msg2