]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage, imap: Move mail_storage_settings.parsed_have_special_use_mailboxes to...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 22 Dec 2023 19:02:15 +0000 (14:02 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
src/imap/imap-client.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-user.c
src/lib-storage/mail-user.h

index 2567666bc4bb0844b28717fa0b0dfa799eaed65e..88839433c97cc66ae626cbb49c20c78e9518f03f 100644 (file)
@@ -85,13 +85,6 @@ static void client_init_urlauth(struct client *client)
        client->urlauth_ctx = imap_urlauth_init(client->user, &config);
 }
 
-static bool user_has_special_use_mailboxes(struct mail_user *user)
-{
-       const struct mail_storage_settings *mail_set =
-               mail_user_set_get_storage_set(user);
-       return mail_set->parsed_have_special_use_mailboxes;
-}
-
 struct client *client_create(int fd_in, int fd_out,
                             enum client_create_flags flags,
                             struct event *event, struct mail_user *user,
@@ -190,7 +183,7 @@ struct client *client_create(int fd_in, int fd_out,
        }
        if (set->imap_metadata && have_mailbox_attribute_dict)
                client_add_capability(client, "METADATA");
-       if (user_has_special_use_mailboxes(user)) {
+       if (user->have_special_use_mailboxes) {
                /* Advertise SPECIAL-USE only if there are actually some
                   SPECIAL-USE flags in mailbox configuration. */
                client_add_capability(client, "SPECIAL-USE");
index 58e9224279584f6cb79071b2e84907fc43107231..b407b49dc09b826f52cae6b68f8a4edb3f936ddd 100644 (file)
@@ -428,10 +428,11 @@ static bool mail_cache_fields_parse(const char *key, const char *value,
        }
        return TRUE;
 }
+/* </settings checks> */
 
 static int
 mail_storage_settings_find_ns(struct event *event,
-                             struct mail_storage_settings *set,
+                             const struct mail_storage_settings *set,
                              const char *wanted_name,
                              const struct mail_namespace_settings **ns_r,
                              const char **error_r)
@@ -460,9 +461,9 @@ mail_storage_settings_find_ns(struct event *event,
        return 0;
 }
 
-bool mail_storage_settings_check_namespaces(struct event *event,
-                                           struct mail_storage_settings *set,
-                                           const char **error_r)
+bool mail_user_check_namespace_settings(struct mail_user *user,
+                                       const struct mail_storage_settings *set,
+                                       const char **error_r)
 {
        const struct mail_namespace_settings *ns, *alias_ns;
        const char *ns_name, *error;
@@ -471,7 +472,7 @@ bool mail_storage_settings_check_namespaces(struct event *event,
                return TRUE;
 
        array_foreach_elem(&set->namespaces, ns_name) {
-               if (settings_get_filter(event, "namespace", ns_name,
+               if (settings_get_filter(user->event, "namespace", ns_name,
                                        &mail_namespace_setting_parser_info,
                                        SETTINGS_GET_FLAG_FAKE_EXPAND,
                                        &ns, &error) < 0) {
@@ -487,14 +488,14 @@ bool mail_storage_settings_check_namespaces(struct event *event,
                }
 
                if (ns->parsed_have_special_use_mailboxes)
-                       set->parsed_have_special_use_mailboxes = TRUE;
+                       user->have_special_use_mailboxes = TRUE;
 
                if (ns->alias_for[0] == '\0') {
                        settings_free(ns);
                        continue;
                }
 
-               if (mail_storage_settings_find_ns(event, set,
+               if (mail_storage_settings_find_ns(user->event, set,
                                ns->alias_for, &alias_ns, error_r) < 0) {
                        settings_free(ns);
                        return FALSE;
@@ -522,6 +523,7 @@ bool mail_storage_settings_check_namespaces(struct event *event,
        return TRUE;
 }
 
+/* <settings checks> */
 static bool
 mailbox_list_get_path_setting(const char *key, const char **value,
                              pool_t pool, enum mailbox_list_path_type *type_r)
index be2bea850d992c2f36f2175c937cde86f5d027b9..0cdf15fb18bd8fdc940f9398d9a36b06f1e99a59 100644 (file)
@@ -100,7 +100,6 @@ struct mail_storage_settings {
        bool parsed_mail_attachment_exclude_inlined;
        bool parsed_mail_attachment_detection_add_flags;
        bool parsed_mail_attachment_detection_no_flags_on_fetch;
-       bool parsed_have_special_use_mailboxes;
        /* Filename part of mailbox_list_index_prefix */
        const char *parsed_list_index_fname;
        /* Directory part of mailbox_list_index_prefix. NULL defaults to index
@@ -210,8 +209,8 @@ bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
 void mail_storage_2nd_settings_reset(struct settings_instance *instance,
                                     const char *key_prefix);
 
-bool mail_storage_settings_check_namespaces(struct event *event,
-                                           struct mail_storage_settings *set,
-                                           const char **error_r);
+bool mail_user_check_namespace_settings(struct mail_user *user,
+                                       const struct mail_storage_settings *set,
+                                       const char **error_r);
 
 #endif
index 17dcea0f05d39458157a906e178ee62641f27012..d0eb0ec3302404d219064d5c17c6c1a9fb7c2115 100644 (file)
@@ -147,8 +147,7 @@ int mail_user_init(struct mail_user *user, const char **error_r)
 
        if (settings_get(user->event, &mail_storage_setting_parser_info, 0,
                         &user->_mail_set, &error) < 0 ||
-           !mail_storage_settings_check_namespaces(user->event,
-                                                   user->_mail_set, &error))
+           !mail_user_check_namespace_settings(user, user->_mail_set, &error))
                user->error = p_strdup(user->pool, error);
        else
                mail_user_expand_plugins_envs(user, user->_mail_set);
index 48cc693ae9c79dd55c78d0320f55f359655e9c44..adcd23cd8800982bfa69ba6711f3d1620868beaa 100644 (file)
@@ -108,6 +108,8 @@ struct mail_user {
        bool stats_enabled:1;
        /* This session was restored (e.g. IMAP unhibernation) */
        bool session_restored:1;
+       /* TRUE if any mailboxes have special_use flags */
+       bool have_special_use_mailboxes;
 };
 
 struct mail_user_module_register {