From a2d62437f45fec72f2475631b590187f22a00207 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 28 Sep 2018 13:30:01 +0300 Subject: [PATCH] push-notification-event-messageappend: Include date information parsed from headers Consistency with MessageNew --- .../push-notification-event-messageappend.c | 20 +++++++++++++++++++ .../push-notification-event-messageappend.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/plugins/push-notification/push-notification-event-messageappend.c b/src/plugins/push-notification/push-notification-event-messageappend.c index 41a391d63b..1c6e01fee9 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.c +++ b/src/plugins/push-notification/push-notification-event-messageappend.c @@ -4,8 +4,11 @@ #include "array.h" #include "hash.h" #include "istream.h" +#include "iso8601-date.h" #include "mail-storage.h" +#include + #include "push-notification-drivers.h" #include "push-notification-events.h" #include "push-notification-event-message-common.h" @@ -29,6 +32,13 @@ static void push_notification_event_messageappend_debug_msg (struct push_notification_txn_event *event) { struct push_notification_event_messageappend_data *data = event->data; + struct tm *tm; + + if (data->date != -1) { + tm = gmtime(&data->date); + i_debug("%s: Date [%s]", EVENT_NAME, + iso8601_date_create_tm(tm, data->date_tz)); + } if (data->from != NULL) { i_debug("%s: From [%s]", EVENT_NAME, data->from); @@ -57,6 +67,8 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn, (struct push_notification_event_messageappend_config *)ec->config; struct push_notification_event_messageappend_data *data; const char *value; + time_t date; + int tz; if (config->flags == 0) { return; @@ -66,6 +78,7 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn, if (data == NULL) { data = p_new(ptxn->pool, struct push_notification_event_messageappend_data, 1); + data->date = -1; push_notification_txn_msg_set_eventdata(ptxn, msg, ec, data); } @@ -94,6 +107,13 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn, i_assert(value[0] != '\0'); data->snippet = p_strdup(ptxn->pool, value + 1); } + + if ((data->date == -1) && + (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_DATE) != 0 && + (mail_get_date(mail, &date, &tz) >= 0)) { + data->date = date; + data->date_tz = tz; + } } diff --git a/src/plugins/push-notification/push-notification-event-messageappend.h b/src/plugins/push-notification/push-notification-event-messageappend.h index d903de55d4..c10a10c85d 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.h +++ b/src/plugins/push-notification/push-notification-event-messageappend.h @@ -13,6 +13,9 @@ struct push_notification_event_messageappend_data { const char *to; const char *subject; const char *snippet; + /* PUSH_NOTIFICATION_MESSAGE_HDR_DATE */ + time_t date; + int date_tz; }; -- 2.47.3