]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: Allow easy access to Message-ID header
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 16 Aug 2019 19:07:51 +0000 (22:07 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 05:47:43 +0000 (08:47 +0300)
src/plugins/push-notification/push-notification-driver-lua.c
src/plugins/push-notification/push-notification-event-message-common.h
src/plugins/push-notification/push-notification-event-messageappend.c
src/plugins/push-notification/push-notification-event-messageappend.h
src/plugins/push-notification/push-notification-event-messagenew.c
src/plugins/push-notification/push-notification-event-messagenew.h

index 82caf3a77568d3373b35ef6bcbdea73f83229383..c4e65ff3d33f5654a36f50b96b4b228cd7644453 100644 (file)
@@ -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 */
index 83a46d1ae7ac9f39ade2327c1624c5526d8051dc..58189487ef1ee74073d4ff5e3931f2ca8e11c345 100644 (file)
@@ -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,
 };
 
 
index 0ee0b44cf46d86d3c0fd10456b67241871730baa..d9e39a9ecf29018bad14cede77c2fd9ca8a04e2c 100644 (file)
@@ -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);
+    }
 }
 
 
index bfe812567d6b257d836b88b9648e6ce29b81f30c..ba4e0708966763c715b9e83de22a804e46d189f6 100644 (file)
@@ -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;
 };
 
 
index 892a99a8a385fe5160073977ee2c25e7f02cacd8..3f1c4f3f6ce1d968c0d0357ba89227206729290c 100644 (file)
@@ -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);
+    }
 }
 
 
index bc05c588390d054d161887f4859648eaf9489dc4..149f2def6bafa02955acc126de575dce0f0f5073 100644 (file)
@@ -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;
 };