MAILBOX_TRANSACTION_FLAG_NO_CACHE_DEC = 0x10,
/* Sync transaction describes changes to mailbox that already happened
to another mailbox with whom we're syncing with (dsync) */
- MAILBOX_TRANSACTION_FLAG_SYNC = 0x20
+ MAILBOX_TRANSACTION_FLAG_SYNC = 0x20,
+ /* Don't trigger any notifications for this transaction. This
+ especially means the notify plugin. This would normally be used only
+ with _FLAG_SYNC. */
+ MAILBOX_TRANSACTION_FLAG_NO_NOTIFY = 0x40
};
enum mailbox_sync_flags {
struct mail_vfuncs *v = mail->vlast;
union mail_module_context *lmail;
+ if ((_mail->transaction->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) != 0)
+ return;
+
lmail = p_new(mail->pool, union mail_module_context, 1);
lmail->super = *v;
mail->vlast = &lmail->super;
NOTIFY_CONTEXT(ctx->transaction->box);
int ret;
- if (ctx->dest_mail == NULL) {
+ if (ctx->dest_mail == NULL &&
+ (ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0) {
if (lt->tmp_mail == NULL)
lt->tmp_mail = mail_alloc(ctx->transaction, 0, NULL);
ctx->dest_mail = lt->tmp_mail;
if ((ret = lbox->super.copy(ctx, mail)) < 0)
return -1;
- if (ctx->saving) {
+ if ((ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) != 0) {
+ /* no notifications */
+ } else if (ctx->saving) {
/* we came from mailbox_save_using_mail() */
notify_contexts_mail_save(ctx->dest_mail);
} else {
union mailbox_module_context *lbox =
NOTIFY_CONTEXT(ctx->transaction->box);
- if (ctx->dest_mail == NULL) {
+ if (ctx->dest_mail == NULL &&
+ (ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0) {
if (lt->tmp_mail == NULL)
lt->tmp_mail = mail_alloc(ctx->transaction, 0, NULL);
ctx->dest_mail = lt->tmp_mail;
if (lbox->super.save_finish(ctx) < 0)
return -1;
- if (dest_mail != NULL)
+ if (dest_mail != NULL &&
+ (ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0)
notify_contexts_mail_save(dest_mail);
return 0;
}
lt = i_new(struct notify_transaction_context, 1);
MODULE_CONTEXT_SET(t, notify_storage_module, lt);
- notify_contexts_mail_transaction_begin(t);
+ if ((t->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0)
+ notify_contexts_mail_transaction_begin(t);
return t;
}
return -1;
}
- notify_contexts_mail_transaction_commit(t, changes_r);
+ /* FIXME: note that t is already freed at this stage. it's not actually
+ being dereferenced anymore though. still, a bit unsafe.. */
+ if ((t->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0)
+ notify_contexts_mail_transaction_commit(t, changes_r);
return 0;
}
mail_free(<->tmp_mail);
i_free(lt);
- notify_contexts_mail_transaction_rollback(t);
+ if ((t->flags & MAILBOX_TRANSACTION_FLAG_NO_NOTIFY) == 0)
+ notify_contexts_mail_transaction_rollback(t);
lbox->super.transaction_rollback(t);
}