Mercurial > dovecot > core-2.2
changeset 22016:6389f6b095af
imap: Set FETCH transactions hidden only when \Seen flags are implicitly set
This simplifies implementing some plugins and has no downsides to core
functionality.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 05 May 2017 12:35:23 +0300 |
parents | f425f8ce28de |
children | 62660946454b |
files | src/imap/imap-fetch.c |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-fetch.c Thu May 04 17:31:47 2017 +0300 +++ b/src/imap/imap-fetch.c Fri May 05 12:35:23 2017 +0300 @@ -351,6 +351,8 @@ void imap_fetch_begin(struct imap_fetch_context *ctx, struct mailbox *box, struct mail_search_args *search_args) { + enum mailbox_transaction_flags trans_flags = + MAILBOX_TRANSACTION_FLAG_REFRESH; struct mailbox_header_lookup_ctx *wanted_headers = NULL; const char *const *headers; @@ -370,9 +372,18 @@ array_count(&ctx->all_headers)-1, 1); } - ctx->state.trans = mailbox_transaction_begin(box, - MAILBOX_TRANSACTION_FLAG_HIDE | - MAILBOX_TRANSACTION_FLAG_REFRESH); + if (ctx->flags_update_seen) { + /* Hide the implicit \Seen flag addition. Otherwise a separate + untagged FETCH FLAGS (\Seen) would be sent on top of the + one FLAGS (\Seen) already added in the main FETCH reply. + + We don't set this always, because some plugins might want + to do their own flag changes which we don't want hidden. + (Of course this isn't perfect since if implicit \Seen flags + are added, other flag changes are also hidden.) */ + trans_flags |= MAILBOX_TRANSACTION_FLAG_HIDE; + } + ctx->state.trans = mailbox_transaction_begin(box, trans_flags); mailbox_transaction_set_reason(ctx->state.trans, ctx->reason); mail_search_args_init(search_args, box, TRUE,