]> 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)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 18 Jan 2018 10:14:54 +0000 (12:14 +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 2045b1dd7527775ceca3bae8b2cbdae4e45c724a..7e5b134ec6e076ae1dd97da8d7d668eff30cb679 100644 (file)
@@ -274,7 +274,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;
 
        mbox->exists_count = exists_count;
@@ -352,7 +352,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;
@@ -474,6 +475,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,
@@ -576,7 +582,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 89d43591db5a00ab49aa951ff439ecfaf3218eb2..c215d896d3b77cc0c8eeff847e0c2ce3868dfd5c 100644 (file)
@@ -103,6 +103,7 @@ static const struct imapc_feature_list imapc_feature_list[] = {
        { "delay-login", IMAPC_FEATURE_DELAY_LOGIN },
        { "fetch-bodystructure", IMAPC_FEATURE_FETCH_BODYSTRUCTURE },
        { "fetch-empty-is-expunged", IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED },
+       { "no-msn-updates", IMAPC_FEATURE_NO_MSN_UPDATES },
        { NULL, 0 }
 };
 
index bdf331d985019a679a8d3c7e01219d981ebc982f..f705ec216bcd01b5d5164fc262dedfcc0967fdea 100644 (file)
@@ -19,6 +19,7 @@ enum imapc_features {
        IMAPC_FEATURE_DELAY_LOGIN               = 0x800,
        IMAPC_FEATURE_FETCH_BODYSTRUCTURE       = 0x1000,
        IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED   = 0x4000,
+       IMAPC_FEATURE_NO_MSN_UPDATES            = 0x8000,
 };
 /* </settings checks> */