]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
LAYOUT=index: List INBOX as \NoInferiors when necessary
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Dec 2017 23:31:10 +0000 (01:31 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 14 Dec 2017 08:23:11 +0000 (10:23 +0200)
src/lib-storage/list/mailbox-list-index-iter.c

index c5bd968865b9262aa941d05307913671462cf532..c9afc7a8f9aaa3f64cddbc709eef6302e1920eca 100644 (file)
@@ -85,16 +85,25 @@ mailbox_list_index_update_info(struct mailbox_list_index_iterate_context *ctx)
        str_append(ctx->path, node->name);
 
        ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path));
-       ctx->info.vname = p_strdup(ctx->info_pool, ctx->info.vname);
-       ctx->info.flags = 0;
+       ctx->info.flags = node->children != NULL ?
+               MAILBOX_CHILDREN : MAILBOX_NOCHILDREN;
+       if (strcmp(ctx->info.vname, "INBOX") != 0) {
+               /* non-INBOX */
+               ctx->info.vname = p_strdup(ctx->info_pool, ctx->info.vname);
+       } else {
+               /* listing INBOX itself */
+               ctx->info.vname = "INBOX";
+               if (mail_namespace_is_inbox_noinferiors(ctx->info.ns)) {
+                       ctx->info.flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN);
+                       ctx->info.flags |= MAILBOX_NOINFERIORS;
+               }
+       }
        if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0)
                ctx->info.flags |= MAILBOX_NONEXISTENT;
        else if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0)
                ctx->info.flags |= MAILBOX_NOSELECT;
        if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOINFERIORS) != 0)
                ctx->info.flags |= MAILBOX_NOINFERIORS;
-       ctx->info.flags |= node->children != NULL ?
-               MAILBOX_CHILDREN : MAILBOX_NOCHILDREN;
 
        if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED |
                               MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) {