From: Timo Sirainen Date: Fri, 16 Aug 2019 19:07:51 +0000 (+0300) Subject: push-notification: Allow easy access to Message-ID header X-Git-Tag: 2.3.8~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8cdf7b216ac2ce84e39ff2a325ad18c6cde7027d;p=thirdparty%2Fdovecot%2Fcore.git push-notification: Allow easy access to Message-ID header --- diff --git a/src/plugins/push-notification/push-notification-driver-lua.c b/src/plugins/push-notification/push-notification-driver-lua.c index 82caf3a775..c4e65ff3d3 100644 --- a/src/plugins/push-notification/push-notification-driver-lua.c +++ b/src/plugins/push-notification/push-notification-driver-lua.c @@ -61,7 +61,7 @@ struct dlua_push_notification_txn_context { PUSH_NOTIFICATION_MESSAGE_HDR_FROM | PUSH_NOTIFICATION_MESSAGE_HDR_TO | \ PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT | PUSH_NOTIFICATION_MESSAGE_HDR_DATE | \ PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET | PUSH_NOTIFICATION_MESSAGE_FLAGS | \ - PUSH_NOTIFICATION_MESSAGE_KEYWORDS) + PUSH_NOTIFICATION_MESSAGE_KEYWORDS | PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID) static const char *push_notification_driver_lua_to_fn(const char *evname); @@ -368,6 +368,9 @@ push_notification_lua_push_messageappend(const struct push_notification_txn_even dlua_pushkeywords(script, data->keywords, str_array_length(data->keywords)); lua_setfield(script->L, -2, "keywords"); + + lua_pushstring(script->L, data->message_id); + lua_setfield(script->L, -2, "message_id"); } static void @@ -399,6 +402,9 @@ push_notification_lua_push_messagenew(const struct push_notification_txn_event * dlua_pushkeywords(script, data->keywords, str_array_length(data->keywords)); lua_setfield(script->L, -2, "keywords"); + + lua_pushstring(script->L, data->message_id); + lua_setfield(script->L, -2, "message_id"); } /* events that need special treatment */ diff --git a/src/plugins/push-notification/push-notification-event-message-common.h b/src/plugins/push-notification/push-notification-event-message-common.h index 83a46d1ae7..58189487ef 100644 --- a/src/plugins/push-notification/push-notification-event-message-common.h +++ b/src/plugins/push-notification/push-notification-event-message-common.h @@ -19,6 +19,8 @@ enum push_notification_event_message_flags { PUSH_NOTIFICATION_MESSAGE_FLAGS = 0x20, /* Meta: Keywords */ PUSH_NOTIFICATION_MESSAGE_KEYWORDS = 0x40, + /* Header: Message-ID */ + PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID = 0x80, }; diff --git a/src/plugins/push-notification/push-notification-event-messageappend.c b/src/plugins/push-notification/push-notification-event-messageappend.c index 0ee0b44cf4..d9e39a9ecf 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.c +++ b/src/plugins/push-notification/push-notification-event-messageappend.c @@ -133,6 +133,12 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn, array_append_zero(&kws); data->keywords = array_idx(&kws, 0); } + + if ((data->message_id == NULL) && + (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID) != 0 && + (mail_get_first_header(mail, "Message-ID", &value) >= 0)) { + data->message_id = p_strdup(ptxn->pool, value); + } } diff --git a/src/plugins/push-notification/push-notification-event-messageappend.h b/src/plugins/push-notification/push-notification-event-messageappend.h index bfe812567d..ba4e070896 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.h +++ b/src/plugins/push-notification/push-notification-event-messageappend.h @@ -21,6 +21,8 @@ struct push_notification_event_messageappend_data { enum mail_flags flags; /* PUSH_NOTIFICATION_MESSAGE_KEYWORDS */ const char *const *keywords; + /* PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID */ + const char *message_id; }; diff --git a/src/plugins/push-notification/push-notification-event-messagenew.c b/src/plugins/push-notification/push-notification-event-messagenew.c index 892a99a8a3..3f1c4f3f6c 100644 --- a/src/plugins/push-notification/push-notification-event-messagenew.c +++ b/src/plugins/push-notification/push-notification-event-messagenew.c @@ -134,6 +134,12 @@ push_notification_event_messagenew_event(struct push_notification_txn *ptxn, array_append_zero(&kws); data->keywords = array_idx(&kws, 0); } + + if ((data->message_id == NULL) && + (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID) != 0 && + (mail_get_first_header(mail, "Message-ID", &value) >= 0)) { + data->message_id = p_strdup(ptxn->pool, value); + } } diff --git a/src/plugins/push-notification/push-notification-event-messagenew.h b/src/plugins/push-notification/push-notification-event-messagenew.h index bc05c58839..149f2def6b 100644 --- a/src/plugins/push-notification/push-notification-event-messagenew.h +++ b/src/plugins/push-notification/push-notification-event-messagenew.h @@ -28,6 +28,8 @@ struct push_notification_event_messagenew_data { enum mail_flags flags; /* PUSH_NOTIFICATION_MESSAGE_KEYWORDS */ const char *const *keywords; + /* PUSH_NOTIFICATION_MESSAGE_HDR_MESSAGE_ID */ + const char *message_id; };