From: Aki Tuomi Date: Mon, 7 Jan 2019 18:00:07 +0000 (+0200) Subject: push-notification: Add flags and keywords to MessageAppend event X-Git-Tag: 2.3.9~948 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4305a33f55902cfd8cc4d8fc170c906e50ddd349;p=thirdparty%2Fdovecot%2Fcore.git push-notification: Add flags and keywords to MessageAppend event --- diff --git a/src/plugins/push-notification/push-notification-event-messageappend.c b/src/plugins/push-notification/push-notification-event-messageappend.c index 1c6e01fee9..0ee0b44cf4 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.c +++ b/src/plugins/push-notification/push-notification-event-messageappend.c @@ -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); + } } diff --git a/src/plugins/push-notification/push-notification-event-messageappend.h b/src/plugins/push-notification/push-notification-event-messageappend.h index c10a10c85d..bfe812567d 100644 --- a/src/plugins/push-notification/push-notification-event-messageappend.h +++ b/src/plugins/push-notification/push-notification-event-messageappend.h @@ -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; };