]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: Add flags and keywords to MessageAppend event
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 7 Jan 2019 18:00:07 +0000 (20:00 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Jan 2019 15:23:47 +0000 (17:23 +0200)
src/plugins/push-notification/push-notification-event-messageappend.c
src/plugins/push-notification/push-notification-event-messageappend.h

index 1c6e01fee9739ef76a7c51a47e740490e08f85c9..0ee0b44cf46d86d3c0fd10456b67241871730baa 100644 (file)
@@ -114,6 +114,25 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn,
         data->date = date;
         data->date_tz = tz;
     }
+
+    if (!data->flags_set &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_FLAGS) != 0) {
+        data->flags = mail_get_flags(mail);
+        data->flags_set = TRUE;
+    }
+
+    if ((data->keywords == NULL) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_KEYWORDS) != 0) {
+        const char *const *mail_kws = mail_get_keywords(mail);
+        ARRAY_TYPE(const_string) kws;
+        p_array_init(&kws, ptxn->pool, 2);
+        for (;*mail_kws != NULL; mail_kws++) {
+           value = p_strdup(ptxn->pool, *mail_kws);
+           array_append(&kws, &value, 1);
+        }
+        array_append_zero(&kws);
+        data->keywords = array_idx(&kws, 0);
+    }
 }
 
 
index c10a10c85d4b22c73850785e5dd880ae41308695..bfe812567d6b257d836b88b9648e6ce29b81f30c 100644 (file)
@@ -16,6 +16,11 @@ struct push_notification_event_messageappend_data {
     /* PUSH_NOTIFICATION_MESSAGE_HDR_DATE */
     time_t date;
     int date_tz;
+    /* PUSH_NOTIFICATION_MESSAGE_FLAGS */
+    bool flags_set;
+    enum mail_flags flags;
+    /* PUSH_NOTIFICATION_MESSAGE_KEYWORDS */
+    const char *const *keywords;
 };