mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 06:46:32 +03:00
allow removing quotes on existing drafts (#2950)
allow `dc_msg_set_quote(msg, NULL)` and `msg.set_quote(None)` to simplify draft handling keeping message-ids (as needed for webxdc updates). closes #2948
This commit is contained in:
@@ -4165,7 +4165,8 @@ void dc_msg_latefiling_mediasize (dc_msg_t* msg, int width, int hei
|
||||
*
|
||||
* @memberof dc_msg_t
|
||||
* @param msg The message object to set the reply to.
|
||||
* @param quote The quote to set for msg.
|
||||
* @param quote The quote to set for the message object given as `msg`.
|
||||
* NULL removes an previously set quote.
|
||||
*/
|
||||
void dc_msg_set_quote (dc_msg_t* msg, const dc_msg_t* quote);
|
||||
|
||||
|
||||
@@ -3372,17 +3372,21 @@ pub unsafe extern "C" fn dc_msg_set_quote(msg: *mut dc_msg_t, quote: *const dc_m
|
||||
return;
|
||||
}
|
||||
let ffi_msg = &mut *msg;
|
||||
let ffi_quote = &*quote;
|
||||
|
||||
if ffi_msg.context != ffi_quote.context {
|
||||
eprintln!("ignoring attempt to quote message from a different context");
|
||||
return;
|
||||
}
|
||||
let quote_msg = if quote.is_null() {
|
||||
None
|
||||
} else {
|
||||
let ffi_quote = &*quote;
|
||||
if ffi_msg.context != ffi_quote.context {
|
||||
eprintln!("ignoring attempt to quote message from a different context");
|
||||
return;
|
||||
}
|
||||
Some(&ffi_quote.message)
|
||||
};
|
||||
|
||||
block_on(async move {
|
||||
ffi_msg
|
||||
.message
|
||||
.set_quote(&*ffi_msg.context, &ffi_quote.message)
|
||||
.set_quote(&*ffi_msg.context, quote_msg)
|
||||
.await
|
||||
.log_err(&*ffi_msg.context, "failed to set quote")
|
||||
.ok();
|
||||
|
||||
Reference in New Issue
Block a user