From: Timo Sirainen Date: Fri, 11 Mar 2016 05:01:33 +0000 (+1300) Subject: lazy-expunge: If lazy_expunge is set to namespace root, save all mails to the root... X-Git-Tag: 2.2.24~144 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8281cfda2ef92282bd6ecf77dc9a2fd1e115875e;p=thirdparty%2Fdovecot%2Fcore.git lazy-expunge: If lazy_expunge is set to namespace root, save all mails to the root mailbox. So the difference is: namespace { prefix = expunged/ .. } plugin { # Move expunged mails to expunged/INBOX, expunged/Trash, etc. mailboxes lazy_expunge = expunged/ # Move all expunged mails to "expunged" mailbox, which is the namespace root. lazy_expunge = expunged } --- diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index 55a97c4be9..053f25182b 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -31,6 +31,7 @@ struct lazy_expunge_mail_user { union mail_user_module_context module_ctx; struct mail_namespace *lazy_ns; + const char *lazy_mailbox_vname; const char *env; bool copy_only_last_instance; }; @@ -69,9 +70,14 @@ static MODULE_CONTEXT_DEFINE_INIT(lazy_expunge_mail_user_module, static const char * get_dest_vname(struct mailbox_list *list, struct mailbox *src_box) { + struct lazy_expunge_mail_user *luser = + LAZY_EXPUNGE_USER_CONTEXT(list->ns->user); const char *name; char src_sep, dest_sep; + if (luser->lazy_mailbox_vname != NULL) + return luser->lazy_mailbox_vname; + /* use the (canonical / unaliased) storage name */ name = src_box->name; /* replace hierarchy separators with destination virtual separator */ @@ -435,6 +441,13 @@ lazy_expunge_mail_namespaces_created(struct mail_namespace *namespaces) return; luser->lazy_ns = mail_namespace_find_prefix(namespaces, luser->env); + if (luser->lazy_ns == NULL) { + /* see if it's set to namespace root itself. in that case we + store all the expunged mails to the namespace root. */ + luser->lazy_ns = mail_namespace_find_prefix_nosep(namespaces, luser->env); + luser->lazy_mailbox_vname = p_strndup(namespaces->user->pool, + luser->lazy_ns->prefix, luser->lazy_ns->prefix_len-1); + } if (luser->lazy_ns == NULL) i_fatal("lazy_expunge: Unknown namespace: '%s'", luser->env); mail_namespace_ref(luser->lazy_ns);