Use get_summarytext() for quotes

Co-Authored-By: Hocuri <hocuri@gmx.de>
This commit is contained in:
Alexander Krotov
2020-10-09 14:17:41 +03:00
committed by link2xt
parent ea731a3619
commit eaec03142b
2 changed files with 11 additions and 8 deletions

View File

@@ -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]

View File

@@ -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