Add API to get next fresh message

Rust: Context.get_next_fresh_msg()
C: dc_get_next_fresh_msg()
JSON-RPC: get_next_fresh_msg method
This commit is contained in:
link2xt
2022-11-27 11:37:24 +00:00
parent 08de326930
commit f02888e3cc
5 changed files with 58 additions and 2 deletions

View File

@@ -1243,6 +1243,20 @@ pub unsafe extern "C" fn dc_get_fresh_msgs(
})
}
#[no_mangle]
pub unsafe extern "C" fn dc_get_next_fresh_msg(context: *mut dc_context_t) -> u32 {
if context.is_null() {
eprintln!("ignoring careless call to dc_get_next_fresh_msg()");
return 0;
}
let ctx = &*context;
block_on(ctx.get_next_fresh_msg())
.log_err(ctx, "Failed to get next fresh message")
.unwrap_or_default()
.to_u32()
}
#[no_mangle]
pub unsafe extern "C" fn dc_marknoticed_chat(context: *mut dc_context_t, chat_id: u32) {
if context.is_null() {