mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
add chat.get_summary
(returns a lot like the original function chatlit.getsummary but it doesn't need a chatlist to work)
This commit is contained in:
@@ -2439,6 +2439,32 @@ dc_lot_t* dc_chatlist_get_summary (const dc_chatlist_t* chatlist, siz
|
||||
dc_context_t* dc_chatlist_get_context (dc_chatlist_t* chatlist);
|
||||
|
||||
|
||||
/**
|
||||
* Get a summary for a chat (same as dc_chatlist_get_summary only without the chatlist).
|
||||
*
|
||||
* The summary is returned by a dc_lot_t object with the following fields:
|
||||
*
|
||||
* - dc_lot_t::text1: contains the username or the strings "Me", "Draft" and so on.
|
||||
* The string may be colored by having a look at text1_meaning.
|
||||
* If there is no such name or it should not be displayed, the element is NULL.
|
||||
*
|
||||
* - dc_lot_t::text1_meaning: one of DC_TEXT1_USERNAME, DC_TEXT1_SELF or DC_TEXT1_DRAFT.
|
||||
* Typically used to show dc_lot_t::text1 with different colors. 0 if not applicable.
|
||||
*
|
||||
* - dc_lot_t::text2: contains an excerpt of the message text or strings as
|
||||
* "No messages". May be NULL of there is no such text (eg. for the archive link)
|
||||
*
|
||||
* - dc_lot_t::timestamp: the timestamp of the message. 0 if not applicable.
|
||||
*
|
||||
* - dc_lot_t::state: The state of the message as one of the DC_STATE_* constants (see #dc_msg_get_state()). 0 if not applicable.
|
||||
*
|
||||
* @memberof dc_chat_t
|
||||
* @param context
|
||||
* @param chat The chat object.
|
||||
* @return The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned.
|
||||
*/
|
||||
dc_lot_t* dc_chat_get_summary (dc_context_t* context, dc_chat_t* chat);
|
||||
|
||||
/**
|
||||
* Get info summary for a chat, in json format.
|
||||
*
|
||||
|
||||
@@ -2319,6 +2319,23 @@ pub unsafe extern "C" fn dc_chat_get_visibility(chat: *mut dc_chat_t) -> libc::c
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_chat_get_summary(
|
||||
context: *mut dc_context_t,
|
||||
chat: *mut dc_chat_t,
|
||||
) -> *mut dc_lot_t {
|
||||
if chat.is_null() {
|
||||
eprintln!("ignoring careless call to dc_chat_get_summary()");
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let ffi_chat = &*chat;
|
||||
let ctx = &*context;
|
||||
block_on(async move {
|
||||
let lot = ffi_chat.chat.get_summary(&ctx).await;
|
||||
Box::into_raw(Box::new(lot))
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_chat_is_unpromoted(chat: *mut dc_chat_t) -> libc::c_int {
|
||||
if chat.is_null() {
|
||||
|
||||
Reference in New Issue
Block a user