From: Marco Bettini Date: Wed, 20 Jul 2022 13:40:44 +0000 (+0000) Subject: push-notification: struct push_notification_event_config - Add and propagate log_event X-Git-Tag: 2.4.0~3746 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a1736dae39f636dc4a1befed62940dfa945fdbb;p=thirdparty%2Fdovecot%2Fcore.git push-notification: struct push_notification_event_config - Add and propagate log_event --- diff --git a/src/plugins/push-notification/push-notification-driver-dlog.c b/src/plugins/push-notification/push-notification-driver-dlog.c index 51bcbb5eb3..ff6c499175 100644 --- a/src/plugins/push-notification/push-notification-driver-dlog.c +++ b/src/plugins/push-notification/push-notification-driver-dlog.c @@ -66,7 +66,7 @@ push_notification_driver_dlog_begin_txn( i_debug("Called begin_txn push_notification plugin hook."); array_foreach_elem(&push_notification_events, event) - push_notification_event_init(dtxn, event->name, NULL); + push_notification_event_init(dtxn, event->name, NULL, log_event); return TRUE; } diff --git a/src/plugins/push-notification/push-notification-driver-lua.c b/src/plugins/push-notification/push-notification-driver-lua.c index e1178fa774..a0c1c4ed6d 100644 --- a/src/plugins/push-notification/push-notification-driver-lua.c +++ b/src/plugins/push-notification/push-notification-driver-lua.c @@ -155,24 +155,18 @@ push_notification_driver_lua_init_events( e_debug(ctx->event, "Found %s, handling %s event", fn, name); - if (strcmp(name, "MessageNew") == 0) { - push_notification_event_init(dtxn, name, - &ctx->config_mn); - } else if (strcmp(name, "MessageAppend") == 0) { - push_notification_event_init(dtxn, name, - &ctx->config_ma); - } else if (strcmp(name, "FlagsSet") == 0) { - push_notification_event_init(dtxn, name, - &ctx->config_fs); - } else if (strcmp(name, "FlagsClear") == 0) { - push_notification_event_init(dtxn, name, - &ctx->config_fc); - } else if (event->init.default_config != NULL) { - void *config = event->init.default_config(); - push_notification_event_init(dtxn, name, config); - } else { - push_notification_event_init(dtxn, name, NULL); - } + void *config = NULL; + if (strcmp(name, "MessageNew") == 0) + config = &ctx->config_mn; + else if (strcmp(name, "MessageAppend") == 0) + config = &ctx->config_ma; + else if (strcmp(name, "FlagsSet") == 0) + config = &ctx->config_fs; + else if (strcmp(name, "FlagsClear") == 0) + config = &ctx->config_fc; + else if (event->init.default_config != NULL) + config = event->init.default_config(); + push_notification_event_init(dtxn, name, config, ctx->event); } return found_one; diff --git a/src/plugins/push-notification/push-notification-driver-ox.c b/src/plugins/push-notification/push-notification-driver-ox.c index 728cce9afd..962ee54758 100644 --- a/src/plugins/push-notification/push-notification-driver-ox.c +++ b/src/plugins/push-notification/push-notification-driver-ox.c @@ -281,7 +281,7 @@ push_notification_driver_ox_begin_txn(struct push_notification_driver_txn *dtxn) PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT | PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET; push_notification_event_init( - dtxn, "MessageNew", config); + dtxn, "MessageNew", config, dconfig->event); e_debug(dconfig->event, "Handling MessageNew event"); } } diff --git a/src/plugins/push-notification/push-notification-events.c b/src/plugins/push-notification/push-notification-events.c index a71e8a62e5..742557d57c 100644 --- a/src/plugins/push-notification/push-notification-events.c +++ b/src/plugins/push-notification/push-notification-events.c @@ -42,7 +42,8 @@ push_notification_event_find_class(const char *driver) } void push_notification_event_init(struct push_notification_driver_txn *dtxn, - const char *event_name, void *config) + const char *event_name, void *config, + struct event *log_event) { const struct push_notification_event *event; struct push_notification_event_config *ec; @@ -60,6 +61,7 @@ void push_notification_event_init(struct push_notification_driver_txn *dtxn, struct push_notification_event_config, 1); ec->config = config; ec->event = event; + ec->log_event = log_event; array_push_back(&dtxn->ptxn->events, &ec); } diff --git a/src/plugins/push-notification/push-notification-events.h b/src/plugins/push-notification/push-notification-events.h index f20075f4f7..4f10ca6d0b 100644 --- a/src/plugins/push-notification/push-notification-events.h +++ b/src/plugins/push-notification/push-notification-events.h @@ -88,6 +88,7 @@ struct push_notification_event_vfuncs_msg_triggers { struct push_notification_event_config { const struct push_notification_event *event; + struct event *log_event; void *config; }; @@ -113,7 +114,8 @@ ARRAY_TYPE(push_notification_event) *push_notification_get_events(void); void push_notification_event_init(struct push_notification_driver_txn *dtxn, - const char *event_name, void *config); + const char *event_name, void *config, + struct event *event); void push_notification_event_register( const struct push_notification_event *event);