diff --git a/src/imap/cmd-noop.c b/src/imap/cmd-noop.c index af273b528c..01d5c8c25f 100644 --- a/src/imap/cmd-noop.c +++ b/src/imap/cmd-noop.c @@ -1,9 +1,15 @@ /* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */ #include "imap-common.h" +#include "imap-notify.h" #include "imap-commands.h" bool cmd_noop(struct client_command_context *cmd) { + if (cmd->client->notify_ctx != NULL) { + /* flush any delayed notifications now. this is mainly useful + for testing. */ + imap_notify_flush(cmd->client->notify_ctx); + } return cmd_sync(cmd, 0, IMAP_SYNC_FLAG_SAFE, "OK NOOP completed."); } diff --git a/src/imap/imap-notify.c b/src/imap/imap-notify.c index c2020166db..88de0f47bf 100644 --- a/src/imap/imap-notify.c +++ b/src/imap/imap-notify.c @@ -522,3 +522,13 @@ void imap_notify_deinit(struct imap_notify_context **_ctx) imap_fetch_free(&ctx->fetch_ctx); pool_unref(&ctx->pool); } + +void imap_notify_flush(struct imap_notify_context *ctx) +{ + struct imap_notify_namespace *notify_ns; + + array_foreach_modifiable(&ctx->namespaces, notify_ns) { + if (notify_ns->notify != NULL) + mailbox_list_notify_flush(notify_ns->notify); + } +} diff --git a/src/imap/imap-notify.h b/src/imap/imap-notify.h index 43f0dbbbf1..46e7b2b21c 100644 --- a/src/imap/imap-notify.h +++ b/src/imap/imap-notify.h @@ -69,4 +69,6 @@ void imap_client_notify_command_freed(struct client *client); int imap_notify_begin(struct imap_notify_context *ctx); void imap_notify_deinit(struct imap_notify_context **ctx); +void imap_notify_flush(struct imap_notify_context *ctx); + #endif