bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2015-2018 Dovecot authors, see the included COPYING file */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz#include "push-notification-event-message-common.h"
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz#include "push-notification-event-messageappend.h"
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstatic struct push_notification_event_messageappend_config default_config;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstatic void *push_notification_event_messageappend_default_config(void)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstatic void push_notification_event_messageappend_debug_msg
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz(struct push_notification_txn_event *event)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_event_messageappend_data *data = event->data;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz i_debug("%s: From [%s]", EVENT_NAME, data->from);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz i_debug("%s: Snippet [%s]", EVENT_NAME, data->snippet);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz i_debug("%s: Subject [%s]", EVENT_NAME, data->subject);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz i_debug("%s: To [%s]", EVENT_NAME, data->to);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzpush_notification_event_messageappend_event(struct push_notification_txn *ptxn,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_event_config *ec,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_event_messageappend_config *config =
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz (struct push_notification_event_messageappend_config *)ec->config;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_event_messageappend_data *data;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz data = push_notification_txn_msg_get_eventdata(msg, EVENT_NAME);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct push_notification_event_messageappend_data, 1);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz push_notification_txn_msg_set_eventdata(ptxn, msg, ec, data);
23bdbb7b1831785c6ba6df190f6369da882d2b9dTimo Sirainen (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_TO) != 0 &&
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz (mail_get_first_header(mail, "To", &value) >= 0)) {
23bdbb7b1831785c6ba6df190f6369da882d2b9dTimo Sirainen (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_FROM) != 0 &&
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz (mail_get_first_header(mail, "From", &value) >= 0)) {
23bdbb7b1831785c6ba6df190f6369da882d2b9dTimo Sirainen (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT) != 0 &&
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz (mail_get_first_header(mail, "Subject", &value) >= 0)) {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz data->subject = p_strdup(ptxn->pool, value);
23bdbb7b1831785c6ba6df190f6369da882d2b9dTimo Sirainen (config->flags & PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET) != 0 &&
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz (mail_get_special(mail, MAIL_FETCH_BODY_SNIPPET, &value) >= 0)) {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* [0] contains the snippet algorithm, skip over it */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz data->snippet = p_strdup(ptxn->pool, value + 1);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz/* Event definition */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzextern struct push_notification_event push_notification_event_messageappend;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct push_notification_event push_notification_event_messageappend = {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz .default_config = push_notification_event_messageappend_default_config
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz .debug_msg = push_notification_event_messageappend_debug_msg