]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Add STATUS (DELETED)
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 10 Nov 2025 16:31:08 +0000 (16:31 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 24 Nov 2025 12:20:11 +0000 (12:20 +0000)
src/lib-storage/index/imapc/imapc-storage.c

index 8ab403ec7f1b968c216f436fc3914026a78b836d..499f8a6e2ea849acb66c7918c550ac1731fcec28 100644 (file)
@@ -980,6 +980,8 @@ static void imapc_untagged_status(const struct imapc_untagged_reply *reply,
                        status->uidvalidity = num;
                else if (strcasecmp(key, "UNSEEN") == 0)
                        status->unseen = num;
+               else if (strcasecmp(key, "DELETED") == 0)
+                       status->deleted = num;
                else if (strcasecmp(key, "HIGHESTMODSEQ") == 0 &&
                         imapc_mailbox_has_modseqs(storage->cur_status_box))
                        status->highest_modseq = num;
@@ -1198,6 +1200,8 @@ static int imapc_mailbox_run_status(struct mailbox *box,
        if ((items & STATUS_RECENT) != 0 &&
            (box->enabled_features & MAILBOX_FEATURE_IMAP4REV2) == 0)
                str_append(str, " RECENT");
+       if ((items & STATUS_DELETED) != 0)
+               str_append(str, " DELETED");
        if ((items & STATUS_UIDNEXT) != 0)
                str_append(str, " UIDNEXT");
        if ((items & STATUS_UIDVALIDITY) != 0)
@@ -1213,6 +1217,17 @@ static int imapc_mailbox_run_status(struct mailbox *box,
                return 0;
        }
 
+       if (imapc_client_is_server_selected(mbox->storage->client->client,
+                                           mailbox_get_name(box))) {
+               /* Our local imap session is no longer selecting the folder,
+                  (this is handled in the imap layer above us), but the remote
+                  side still has the mailbox selected. This would cause the
+                  STATUS command below to not work as intended - so, deselect
+                  on the remote side */
+               if (imapc_server_unselect(mbox->storage->client) < 0)
+                       return -1;
+       }
+
        imapc_simple_context_init(&sctx, mbox->storage->client);
        mbox->storage->cur_status_box = mbox;
        mbox->storage->cur_status = status_r;