]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: struct push_notification_event_config - Add and propagate log_event
authorMarco Bettini <marco.bettini@open-xchange.com>
Wed, 20 Jul 2022 13:40:44 +0000 (13:40 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Wed, 20 Jul 2022 15:26:21 +0000 (15:26 +0000)
src/plugins/push-notification/push-notification-driver-dlog.c
src/plugins/push-notification/push-notification-driver-lua.c
src/plugins/push-notification/push-notification-driver-ox.c
src/plugins/push-notification/push-notification-events.c
src/plugins/push-notification/push-notification-events.h

index 51bcbb5eb35c64a47578d47b92b2413b570324c8..ff6c49917585075fc736fa1dc22878530c0c270c 100644 (file)
@@ -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;
 }
 
index e1178fa774fef36942956ba0e34bd53be85b5688..a0c1c4ed6d18929b369348d90576575d682cb0ac 100644 (file)
@@ -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;
index 728cce9afdfafed16b7f3cebd72d12082c23b10c..962ee54758140aed2c9bd9af3e6ef3359a107394 100644 (file)
@@ -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");
                }
        }
index a71e8a62e551f2774139c245b65911b977e3b7ce..742557d57c726def8aca89b00900d6648c33e19f 100644 (file)
@@ -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);
        }
index f20075f4f70020afcbbd32396ca5b7b8978fa5c3..4f10ca6d0b67b6b2b8a2a8a012f98d708c464294 100644 (file)
@@ -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);