From e425976a1ff9da388462a4799e4552c732ce8f83 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 13 Aug 2009 20:45:55 -0400 Subject: [PATCH] tb-extra-mailbox-sep workaround works better now. Mailbox is subscribed without trailing separator. Unsubscribe tries to remove both with and without separator. --HG-- branch : HEAD --- src/imap/cmd-subscribe.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/imap/cmd-subscribe.c b/src/imap/cmd-subscribe.c index d2476ab4af..53b75a67c6 100644 --- a/src/imap/cmd-subscribe.c +++ b/src/imap/cmd-subscribe.c @@ -29,7 +29,8 @@ static bool have_listable_namespace_prefix(struct mail_namespace *ns, bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe) { struct mail_namespace *ns, *real_ns; - const char *mailbox, *verify_name, *real_name; + const char *mailbox, *mailbox2 = NULL, *verify_name, *real_name; + bool unsubscribed_mailbox2; /* */ if (!client_read_string_args(cmd, 1, &mailbox)) @@ -64,6 +65,8 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe) mailbox_list_get_hierarchy_sep(ns->list)) { /* verify the validity without the trailing '/' */ verify_name = t_strndup(verify_name, strlen(verify_name)-1); + mailbox2 = mailbox; + mailbox = t_strndup(mailbox, strlen(mailbox)-1); } if (have_listable_namespace_prefix(cmd->client->user->namespaces, @@ -79,9 +82,17 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe) return TRUE; } - if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0) + unsubscribed_mailbox2 = FALSE; + if (!subscribe && mailbox2 != NULL) { + /* try to unsubscribe both "box" and "box/" */ + if (mailbox_list_set_subscribed(ns->list, mailbox2, FALSE) == 0) + unsubscribed_mailbox2 = TRUE; + } + + if (mailbox_list_set_subscribed(ns->list, mailbox, subscribe) < 0 && + !unsubscribed_mailbox2) { client_send_list_error(cmd, ns->list); - else { + } else { client_send_tagline(cmd, subscribe ? "OK Subscribe completed." : "OK Unsubscribe completed."); -- 2.47.3