]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
welcome-plugin: Move script_execute() to welcome_create_box()
authorMarkus Valentin <markus.valentin@open-xchange.com>
Mon, 9 Jan 2023 14:06:54 +0000 (15:06 +0100)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Thu, 2 Feb 2023 07:20:11 +0000 (08:20 +0100)
The welcome script was executed while opening the INBOX only when
the same session had created it. This could have led to unexpectedly not
executing welcome when not opening the mailbox right after it was created.

The original code delayed the welcome script run because mailbox creation
wasn't finished until the mailbox was opened. This seems to have become
fixed at some point.

src/plugins/welcome/welcome-plugin.c

index e98d1260454d71f8fb2e3946d00a4cb76b6f9083..c8653218a948d7eb28be585227566173f605779b 100644 (file)
@@ -85,27 +85,24 @@ welcome_create_box(struct mailbox *box,
                   const struct mailbox_update *update, bool directory)
 {
        struct welcome_mailbox *wbox = WELCOME_CONTEXT(box);
+       const char *cmd;
 
        if (wbox->module_ctx.super.create_box(box, update, directory) < 0)
                return -1;
-       /* the mailbox isn't fully created here yet, so just mark it as created
-          and wait until open() time to actually run it */
-       wbox->created = TRUE;
+       cmd = mail_user_plugin_getenv(box->storage->user, "welcome_script");
+       if (cmd != NULL) {
+               bool wait = mail_user_plugin_getenv_bool(box->storage->user,
+                                                        "welcome_wait");
+               script_execute(box->storage->user, cmd, wait);
+       }
+
        return 0;
 }
 
 static int welcome_open_box(struct mailbox *box)
 {
        struct welcome_mailbox *wbox = WELCOME_CONTEXT(box);
-       const char *cmd;
 
-       cmd = !wbox->created ? NULL :
-               mail_user_plugin_getenv(box->storage->user, "welcome_script");
-       if (cmd != NULL) {
-               bool wait = mail_user_plugin_getenv_bool(box->storage->user,
-                                                        "welcome_wait");
-               script_execute(box->storage->user, cmd, wait);
-       }
        return wbox->module_ctx.super.open(box);
 }