Mercurial > dovecot > core-2.2
changeset 19942:9234cb74bc17
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
}
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 11 Mar 2016 18:01:33 +1300 |
parents | c27d9577b06d |
children | 9dbae3591914 |
files | src/plugins/lazy-expunge/lazy-expunge-plugin.c |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Fri Mar 11 17:57:41 2016 +1300 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Fri Mar 11 18:01:33 2016 +1300 @@ -31,6 +31,7 @@ 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 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 @@ 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);