From 48eed150e55589c0c46e828e5e6afda55ab3085f Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 16 Oct 2018 23:37:23 +0200 Subject: [PATCH] add a function to get the receive time of a message --- src/dc_msg.c | 21 +++++++++++++++++++++ src/deltachat.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/dc_msg.c b/src/dc_msg.c index 88f6b26c..bc814677 100644 --- a/src/dc_msg.c +++ b/src/dc_msg.c @@ -253,6 +253,27 @@ time_t dc_msg_get_timestamp(const dc_msg_t* msg) } +/** + * Get message receive time. + * The receive time is returned as a unix timestamp in seconds. + * + * To get the sending time, use dc_msg_get_timestamp(). + * + * @memberof dc_msg_t + * @param msg The message object. + * @return Receiving time of the message. + * For outgoing messages, 0 is returned. + */ +time_t dc_msg_get_received_timestamp(const dc_msg_t* msg) +{ + if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { + return 0; + } + + return msg->timestamp_rcvd; +} + + /** * Get the text of the message. * If there is no text associated with the message, an empty string is returned. diff --git a/src/deltachat.h b/src/deltachat.h index 2727b7e9..aa90f644 100644 --- a/src/deltachat.h +++ b/src/deltachat.h @@ -500,6 +500,7 @@ uint32_t dc_msg_get_chat_id (const dc_msg_t*); int dc_msg_get_viewtype (const dc_msg_t*); int dc_msg_get_state (const dc_msg_t*); time_t dc_msg_get_timestamp (const dc_msg_t*); +time_t dc_msg_get_received_timestamp(const dc_msg_t*); char* dc_msg_get_text (const dc_msg_t*); char* dc_msg_get_file (const dc_msg_t*); char* dc_msg_get_filename (const dc_msg_t*);