]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: storage - Use fts_settings for autoindex_exclude
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 4 Dec 2023 16:10:41 +0000 (16:10 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
src/lib-storage/Makefile.am
src/lib-storage/mailbox-match-plugin.c [deleted file]
src/lib-storage/mailbox-match-plugin.h [deleted file]
src/plugins/fts/fts-storage.c
src/plugins/fts/fts-user.c
src/plugins/fts/fts-user.h

index 6072c9aafbcf3613ccaa326ccfc75cf67adedc99..497629f98ede35d9b6b2a71c44c1b9c3f8837251 100644 (file)
@@ -60,7 +60,6 @@ libstorage_la_SOURCES = \
        mailbox-list.c \
        mailbox-list-notify.c \
        mailbox-list-register.c \
-       mailbox-match-plugin.c \
        mailbox-recent-flags.c \
        mailbox-search-result.c \
        mailbox-tree.c \
@@ -98,7 +97,6 @@ headers = \
        mailbox-list-iter.h \
        mailbox-list-private.h \
        mailbox-list-notify.h \
-       mailbox-match-plugin.h \
        mailbox-recent-flags.h \
        mailbox-search-result-private.h \
        mailbox-tree.h \
diff --git a/src/lib-storage/mailbox-match-plugin.c b/src/lib-storage/mailbox-match-plugin.c
deleted file mode 100644 (file)
index fc919b1..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright (c) 2021 Dovecot authors, see the included COPYING file */
-
-#include "lib.h"
-#include "array.h"
-#include "str.h"
-#include "wildcard-match.h"
-#include "mail-storage-private.h"
-#include "mailbox-match-plugin.h"
-#include "mailbox-list-private.h"
-
-struct mailbox_match_plugin {
-       ARRAY_TYPE(const_string) patterns;
-};
-
-struct mailbox_match_plugin *
-mailbox_match_plugin_init(struct mail_user *user, const char *set_prefix)
-{
-       struct mailbox_match_plugin *match;
-       string_t *str;
-       const char *value;
-
-       match = i_new(struct mailbox_match_plugin, 1);
-
-       value = mail_user_plugin_getenv(user, set_prefix);
-       if (value == NULL)
-               return match;
-
-       i_array_init(&match->patterns, 16);
-       str = t_str_new(128);
-       for (unsigned int i = 2; value != NULL; i++) {
-               /* value points to user's settings, so there's no need to
-                  strdup() it. */
-               array_push_back(&match->patterns, &value);
-
-               str_truncate(str, 0);
-               str_printfa(str, "%s%u", set_prefix, i);
-
-               value = mail_user_plugin_getenv(user, str_c(str));
-       }
-
-       return match;
-}
-
-bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match,
-                                 struct mailbox *box)
-{
-       const struct mailbox_settings *set;
-       const char *const *special_use;
-       const char *pattern;
-
-       if (!array_is_created(&match->patterns))
-               return FALSE;
-
-       set = mailbox_get_settings(box);
-       special_use = set == NULL ? NULL :
-               t_strsplit_spaces(set->special_use, " ");
-
-       array_foreach_elem(&match->patterns, pattern) {
-               if (pattern[0] == '\\') {
-                       /* \Special-use flag */
-                       if (special_use != NULL &&
-                           str_array_icase_find(special_use, pattern))
-                               return TRUE;
-               } else {
-                       if (wildcard_match(box->vname, pattern))
-                               return TRUE;
-
-                       /* for namespaces with inbox=yes, try to match also without prefix */
-                       if (HAS_ALL_BITS(box->list->ns->flags, NAMESPACE_FLAG_INBOX_USER) &&
-                           wildcard_match(box->vname + box->list->ns->prefix_len, pattern))
-                               return TRUE;
-               }
-       }
-       return FALSE;
-}
-
-void mailbox_match_plugin_deinit(struct mailbox_match_plugin **_match)
-{
-       struct mailbox_match_plugin *match = *_match;
-
-       if (match == NULL)
-               return;
-       *_match = NULL;
-
-       array_free(&match->patterns);
-       i_free(match);
-}
diff --git a/src/lib-storage/mailbox-match-plugin.h b/src/lib-storage/mailbox-match-plugin.h
deleted file mode 100644 (file)
index c6dbfe9..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef MAILBOX_MATCH_PLUGIN_H
-#define MAILBOX_MATCH_PLUGIN_H
-
-struct mailbox;
-
-/* Utility library to allow a Dovecot plugin an easy way to configure a list
-   of mailbox patterns and special-use flags that can be matched against. */
-
-struct mailbox_match_plugin *
-mailbox_match_plugin_init(struct mail_user *user, const char *set_prefix);
-void mailbox_match_plugin_deinit(struct mailbox_match_plugin **match);
-
-bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match,
-                                 struct mailbox *box);
-
-#endif
index 5030d5eec9a6dca68f030eb2bb9ba770668a72a4..cb7b86d599a0e76ae1320faae1464cd611e258c9 100644 (file)
@@ -48,7 +48,6 @@ struct fts_mailbox {
        union mailbox_module_context module_ctx;
        const struct fts_settings *set;
        struct fts_backend_update_context *sync_update_ctx;
-       bool fts_mailbox_excluded;
 };
 
 struct fts_transaction_context {
@@ -663,15 +662,13 @@ fts_transaction_commit(struct mailbox_transaction_context *t,
                       struct mail_transaction_commit_changes *changes_r)
 {
        struct mailbox *box = t->box;
-       const struct fts_settings *set = fts_user_get_settings(box->storage->user);
        struct fts_transaction_context *ft = FTS_CONTEXT_REQUIRE(t);
        struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(box);
        bool autoindex;
        int ret = 0;
        const char *error;
 
-       autoindex = set->autoindex && ft->mails_saved &&
-                   !fbox->fts_mailbox_excluded;
+       autoindex = fbox->set->autoindex && ft->mails_saved;
 
        if (fts_transaction_end(t, &error) < 0) {
                mail_storage_set_error(t->box->storage, MAIL_ERROR_TEMP,
@@ -833,8 +830,6 @@ void fts_mailbox_allocated(struct mailbox *box)
        v->free = fts_mailbox_free;
        fbox->set = set;
        box->vlast = &fbox->module_ctx.super;
-       fbox->fts_mailbox_excluded = fts_user_autoindex_exclude(box);
-
        v->get_status = fts_mailbox_get_status;
        v->search_init = fts_mailbox_search_init;
        v->search_next_nonblock = fts_mailbox_search_next_nonblock;
index e83f99e62c1c6950096877948329112f83916975..48964908a7414217c539fed9b1cccec67e441618 100644 (file)
@@ -5,7 +5,6 @@
 #include "str-parse.h"
 #include "mail-user.h"
 #include "mail-storage-private.h"
-#include "mailbox-match-plugin.h"
 #include "language.h"
 #include "lang-filter.h"
 #include "lang-tokenizer.h"
@@ -26,8 +25,6 @@ struct fts_user {
        struct language_list *lang_list;
        struct fts_user_language *data_lang;
        ARRAY_TYPE(fts_user_language) languages, data_languages;
-
-       struct mailbox_match_plugin *autoindex_exclude;
 };
 
 static MODULE_CONTEXT_DEFINE_INIT(fts_user_module,
@@ -350,13 +347,6 @@ const struct fts_settings *fts_user_get_settings(struct mail_user *user)
        return fuser->set;
 }
 
-bool fts_user_autoindex_exclude(struct mailbox *box)
-{
-       struct fts_user *fuser = FTS_USER_CONTEXT_REQUIRE(box->storage->user);
-
-       return mailbox_match_plugin_exclude(fuser->autoindex_exclude, box);
-}
-
 int fts_user_try_get_settings(struct mail_user *user,
                              const struct fts_settings **set_r)
 {
@@ -435,8 +425,6 @@ int fts_mail_user_init(struct mail_user *user, bool initialize_libfts,
                        return -1;
                }
        }
-       fuser->autoindex_exclude =
-               mailbox_match_plugin_init(user, "fts_autoindex_exclude");
 
        MODULE_CONTEXT_SET(user, fts_user_module, fuser);
        return 0;
index 1ba3763a716a05fbf4b7a1221db11ff0815e0ff0..6fa4ea0c49fee1e18dcb21f1a44f216f658e1ae3 100644 (file)
@@ -24,7 +24,6 @@ const struct fts_settings *fts_user_get_settings(struct mail_user *user);
 int fts_user_try_get_settings(struct mail_user *user,
                              const struct fts_settings **set_r);
 
-bool fts_user_autoindex_exclude(struct mailbox *box);
 size_t fts_mail_user_message_max_size(struct mail_user *user);
 
 int fts_mail_user_init(struct mail_user *user, bool initialize_libfts,