From: Stephan Bosch Date: Tue, 19 Sep 2017 19:08:38 +0000 (+0200) Subject: lib-storage: Implemented mailbox_is_autosubscribed(). X-Git-Tag: 2.3.0.rc1~935 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ceb75f820c9415b767a17e1f4830c75093ab867;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Implemented mailbox_is_autosubscribed(). Indicates whether the mailbox is automatically subscribed to when it is automatically created. --- diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 9c9e9161c3..78e307f18c 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -779,6 +779,8 @@ int mailbox_create_missing_dir(struct mailbox *box, enum mailbox_list_path_type type); /* Returns TRUE if mailbox is autocreated. */ bool mailbox_is_autocreated(struct mailbox *box); +/* Returns TRUE if mailbox is autosubscribed. */ +bool mailbox_is_autosubscribed(struct mailbox *box); /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */ int mailbox_create_fd(struct mailbox *box, const char *path, int flags, diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index c6306e578a..43d52b5985 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -884,6 +884,12 @@ bool mailbox_is_autocreated(struct mailbox *box) strcmp(box->set->autocreate, MAILBOX_SET_AUTO_NO) != 0; } +bool mailbox_is_autosubscribed(struct mailbox *box) +{ + return box->set != NULL && + strcmp(box->set->autocreate, MAILBOX_SET_AUTO_SUBSCRIBE) == 0; +} + static int mailbox_autocreate(struct mailbox *box) { const char *errstr; @@ -897,9 +903,7 @@ static int mailbox_autocreate(struct mailbox *box) box->vname, errstr); return -1; } - } else if (box->set != NULL && - strcmp(box->set->autocreate, - MAILBOX_SET_AUTO_SUBSCRIBE) == 0) { + } else if (mailbox_is_autosubscribed(box)) { if (mailbox_set_subscribed(box, TRUE) < 0) { mail_storage_set_critical(box->storage, "Failed to autosubscribe to mailbox %s: %s",