mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
resend messages using the same Message-ID (#3238)
* add dc_resend_msgs() to ffi * add 'resend' to repl * implement resend_msgs() * allow only resending if allowed by chat-protection this means, resending is denied if a chat is protected and we cannot encrypt (normally, however, we should not arrive in that state) * allow only resending of normal, non-info-messages * allow only resending of own messages * reset sending state to OutPending on resending the resulting state is always OutDelivered first, OutMdnRcvd again would be applied when a read receipt is received. preserving old state is doable, however, maybe this simple approach is also good enough, at least for now (or maybe the simple approach is even just fine :) another thing: when we upgrade to resending foreign messages, we do not have a simple way to mark them as pending as incoming message just do not have such a state - but this is sth. for the future.
This commit is contained in:
@@ -1801,6 +1801,25 @@ void dc_delete_msgs (dc_context_t* context, const uint3
|
||||
void dc_forward_msgs (dc_context_t* context, const uint32_t* msg_ids, int msg_cnt, uint32_t chat_id);
|
||||
|
||||
|
||||
/**
|
||||
* Resend messages and make information available for newly added chat members.
|
||||
* Resending sends out the original message, however, recipients and webxdc-status may differ.
|
||||
* Clients that already have the original message can still ignore the resent message as
|
||||
* they have tracked the state by dedicated updates.
|
||||
*
|
||||
* Some messages cannot be resent, eg. info-messages, drafts, already pending messages or messages that are not sent by SELF.
|
||||
* In this case, the return value indicates an error and the error string from dc_get_last_error() should be shown to the user.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
* @param msg_ids An array of uint32_t containing all message IDs that should be resend.
|
||||
* All messages must belong to the same chat.
|
||||
* @param msg_cnt The number of messages IDs in the msg_ids array.
|
||||
* @return 1=all messages are queued for resending, 0=error
|
||||
*/
|
||||
int dc_resend_msgs (dc_context_t* context, const uint32_t* msg_ids, int msg_cnt);
|
||||
|
||||
|
||||
/**
|
||||
* Mark messages as presented to the user.
|
||||
* Typically, UIs call this function on scrolling through the message list,
|
||||
|
||||
@@ -1751,6 +1751,27 @@ pub unsafe extern "C" fn dc_forward_msgs(
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_resend_msgs(
|
||||
context: *mut dc_context_t,
|
||||
msg_ids: *const u32,
|
||||
msg_cnt: libc::c_int,
|
||||
) -> libc::c_int {
|
||||
if context.is_null() || msg_ids.is_null() || msg_cnt <= 0 {
|
||||
eprintln!("ignoring careless call to dc_resend_msgs()");
|
||||
return 0;
|
||||
}
|
||||
let ctx = &*context;
|
||||
let msg_ids = convert_and_prune_message_ids(msg_ids, msg_cnt);
|
||||
|
||||
if let Err(err) = block_on(chat::resend_msgs(ctx, &msg_ids)) {
|
||||
error!(ctx, "Resending failed: {}", err);
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_markseen_msgs(
|
||||
context: *mut dc_context_t,
|
||||
|
||||
Reference in New Issue
Block a user