]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Add imapc_features=no-msn-updates
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Dec 2017 09:10:19 +0000 (11:10 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 25 Dec 2017 20:09:39 +0000 (22:09 +0200)
This is a stricter version of fetch-msn-workarounds. The MSNs aren't trusted
at all. This means any new untagged EXISTS and EXPUNGE replies are ignored,
as well as untagged FETCH replies that don't include UID.

A potential downside with this feature is that UID FETCH/STORE commands
sent to expunged messages will likely fail without the IMAP client being
notified of the EXPUNGEs. New mails are also not noticed, so this should
be used only when it's known that the clients don't keep the connection
open for long.

src/lib-storage/index/imapc/imapc-mailbox.c
src/lib-storage/index/imapc/imapc-settings.c
src/lib-storage/index/imapc/imapc-settings.h

index 453ef70a9e29c16ec5df43d81f14201a78ef49b1..a94b0dbd82759ef8c942ed749a136740b0d3782f 100644 (file)
@@ -151,7 +151,7 @@ imapc_untagged_exists(const struct imapc_untagged_reply *reply,
        uint32_t exists_count = reply->num;
        const struct mail_index_header *hdr;
 
-       if (mbox == NULL)
+       if (mbox == NULL || IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))
                return;
 
        view = mbox->delayed_sync_view;
@@ -227,7 +227,8 @@ imapc_mailbox_msgmap_update(struct imapc_mailbox *mbox,
        msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box);
        msg_count = imapc_msgmap_count(msgmap);
        if (fetch_uid != 0 &&
-           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS)) {
+           (IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS) ||
+            IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))) {
                /* if we know the UID, use own own generated rseq instead of
                   the potentially broken rseq that the server sent. */
                uint32_t fixed_rseq;
@@ -349,6 +350,11 @@ static void imapc_untagged_fetch(const struct imapc_untagged_reply *reply,
                        }
                }
        }
+       if (fetch_uid == 0 &&
+           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES)) {
+               /* UID missing and we're not tracking MSNs */
+               return;
+       }
 
        imapc_mailbox_init_delayed_trans(mbox);
        if (imapc_mailbox_msgmap_update(mbox, rseq, fetch_uid,
@@ -453,7 +459,8 @@ static void imapc_untagged_expunge(const struct imapc_untagged_reply *reply,
        struct imapc_msgmap *msgmap;
        uint32_t lseq, uid, rseq = reply->num;
        
-       if (mbox == NULL || rseq == 0)
+       if (mbox == NULL || rseq == 0 ||
+           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))
                return;
 
        mbox->prev_skipped_rseq = 0;
index 676e85d87aa36282f1e0db8a87db0afab5c449a4..6fcd92aedf319068cd71e9173341d6b9225efcb7 100644 (file)
@@ -104,6 +104,7 @@ static const struct imapc_feature_list imapc_feature_list[] = {
        { "fetch-bodystructure", IMAPC_FEATURE_FETCH_BODYSTRUCTURE },
        { "send-id", IMAPC_FEATURE_SEND_ID },
        { "fetch-empty-is-expunged", IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED },
+       { "no-msn-updates", IMAPC_FEATURE_NO_MSN_UPDATES },
        { NULL, 0 }
 };
 
index 038bc4e3d1c0e5ce3f95b0dc8e7a6abeb44d37ab..8b92a3b6f55c2c3743cbab40cb524d4bf8bc2a3f 100644 (file)
@@ -20,6 +20,7 @@ enum imapc_features {
        IMAPC_FEATURE_FETCH_BODYSTRUCTURE       = 0x1000,
        IMAPC_FEATURE_SEND_ID                   = 0x2000,
        IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED   = 0x4000,
+       IMAPC_FEATURE_NO_MSN_UPDATES            = 0x8000,
 };
 /* </settings checks> */