]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail-storage - Merge mailbox_alloc_delivery() into mailbox_alloc_for_user().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 2 Oct 2019 22:43:07 +0000 (00:43 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 8 Oct 2019 00:12:24 +0000 (02:12 +0200)
Uses the MAILBOX_FLAG_POST_SESSION flag.

src/lib-lda/mail-deliver.c
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index d1d3d499aa7ce16dd574d25948205a65a12c8feb..c4761aed5014db2eb55faac5508d23eeccf45977 100644 (file)
@@ -227,7 +227,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx,
                           enum mail_error *error_r, const char **error_str_r)
 {
        struct mailbox *box;
-       enum mailbox_flags flags = 0;
+       enum mailbox_flags flags = MAILBOX_FLAG_POST_SESSION;
 
        *box_r = NULL;
        *error_r = MAIL_ERROR_NONE;
@@ -243,7 +243,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx,
                flags |= MAILBOX_FLAG_AUTO_CREATE;
        if (ctx->lda_mailbox_autosubscribe)
                flags |= MAILBOX_FLAG_AUTO_SUBSCRIBE;
-       *box_r = box = mailbox_alloc_delivery(ctx->user, name, flags);
+       *box_r = box = mailbox_alloc_for_user(ctx->user, name, flags);
 
        if (mailbox_open(box) == 0)
                return 0;
index faddf57b09d7d3fc58fddc7af9edff3e8c3657b5..7ebfbc2d832c89b2793ddab0911e36ed3d4cb529 100644 (file)
@@ -919,33 +919,25 @@ mailbox_alloc_for_user(struct mail_user *user, const char *vname,
 
        ns = mail_namespace_find(user->namespaces, vname);
 
-       return mailbox_alloc(ns->list, vname, flags);
-}
-
-struct mailbox *mailbox_alloc_delivery(struct mail_user *user,
-       const char *name, enum mailbox_flags flags)
-{
-       struct mail_namespace *ns;
-       
-       flags |= MAILBOX_FLAG_SAVEONLY |
-               MAILBOX_FLAG_POST_SESSION;
+       if (HAS_ALL_BITS(flags, MAILBOX_FLAG_POST_SESSION)) {
+               flags |= MAILBOX_FLAG_SAVEONLY;
 
-       ns = mail_namespace_find(user->namespaces, name);
-       if (strcmp(name, ns->prefix) == 0 &&
-           (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
-               /* delivering to a namespace prefix means we actually want to
-                  deliver to the INBOX instead */
-               name = "INBOX";
-               ns = mail_namespace_find_inbox(user->namespaces);
-       }
+               if (strcmp(vname, ns->prefix) == 0 &&
+                   (ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
+                       /* delivering to a namespace prefix means we actually
+                          want to deliver to the INBOX instead */
+                       vname = "INBOX";
+                       ns = mail_namespace_find_inbox(user->namespaces);
+               }
 
-       if (strcasecmp(name, "INBOX") == 0) {
-               /* deliveries to INBOX must always succeed,
-                  regardless of ACLs */
-               flags |= MAILBOX_FLAG_IGNORE_ACLS;
+               if (strcasecmp(vname, "INBOX") == 0) {
+                       /* deliveries to INBOX must always succeed,
+                          regardless of ACLs */
+                       flags |= MAILBOX_FLAG_IGNORE_ACLS;
+               }
        }
 
-       return mailbox_alloc(ns->list, name, flags);
+       return mailbox_alloc(ns->list, vname, flags);
 }
 
 void mailbox_set_reason(struct mailbox *box, const char *reason)
index 81535311a04543816ad8b65e3094aed3d1ac4242..0bff34621a54d0867b6d47105eeb7631ccff9a89 100644 (file)
@@ -527,10 +527,7 @@ struct mailbox *mailbox_alloc_guid(struct mailbox_list *list,
 struct mailbox *
 mailbox_alloc_for_user(struct mail_user *user, const char *vname,
                       enum mailbox_flags flags);
-/* Initialize mailbox for delivery without actually opening any files or
-   verifying that it exists. */
-struct mailbox *mailbox_alloc_delivery(struct mail_user *user,
-       const char *name, enum mailbox_flags flags);
+
 /* Set a human-readable reason for why this mailbox is being accessed.
    This is used for logging purposes. */
 void mailbox_set_reason(struct mailbox *box, const char *reason);