]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
LIST-STATUS: When listing subscriptions, don't return STATUS for unsubscribed parents.
authorTimo Sirainen <tss@iki.fi>
Sat, 6 Mar 2010 10:17:13 +0000 (12:17 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 6 Mar 2010 10:17:13 +0000 (12:17 +0200)
--HG--
branch : HEAD

src/imap/cmd-list.c

index 2c4bd55894b4fbcbb20f0baa3c88c3cc16d154d7..df4bcbf5180092332cc11236b4f7f7f824c903d4 100644 (file)
@@ -325,11 +325,22 @@ list_namespace_send_prefix(struct cmd_list_context *ctx, bool have_children)
        client_send_line(ctx->cmd->client, str_c(str));
 }
 
-static void list_send_status(struct cmd_list_context *ctx, const char *name)
+static void list_send_status(struct cmd_list_context *ctx, const char *name,
+                            enum mailbox_info_flags flags)
 {
        struct imap_status_result result;
        const char *storage_name, *error;
 
+       if ((flags & (MAILBOX_NONEXISTENT | MAILBOX_NOSELECT)) != 0) {
+               /* doesn't exist, don't even try to get STATUS */
+               return;
+       }
+       if ((flags & MAILBOX_SUBSCRIBED) == 0 &&
+           (flags & MAILBOX_CHILD_SUBSCRIBED) != 0) {
+               /* listing subscriptions, but only child is subscribed */
+               return;
+       }
+
        storage_name = mail_namespace_get_storage_name(ctx->ns, name);
        if (imap_status_get(ctx->cmd, ctx->ns, storage_name,
                            &ctx->status_items, &result, &error) < 0) {
@@ -400,12 +411,9 @@ list_namespace_mailboxes(struct cmd_list_context *ctx)
                mailbox_childinfo2str(ctx, str, flags);
 
                ret = client_send_line(ctx->cmd->client, str_c(str));
-               if (ctx->used_status &&
-                   (flags & (MAILBOX_NONEXISTENT | MAILBOX_NOSELECT)) == 0) {
-                       T_BEGIN {
-                               list_send_status(ctx, name);
-                       } T_END;
-               }
+               if (ctx->used_status) T_BEGIN {
+                       list_send_status(ctx, name, flags);
+               } T_END;
                if (ret == 0) {
                        /* buffer is full, continue later */
                        return 0;