]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Use new var_expand
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 29 Aug 2024 10:49:38 +0000 (13:49 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:00 +0000 (10:40 +0200)
src/submission/submission-client.c
src/submission/submission-settings.c

index a13ffc217ad95549515951b785d8d07fb8d85d67..cf190c9130994d570f6b4127e63bab6b4b45ec26 100644 (file)
@@ -10,7 +10,6 @@
 #include "istream.h"
 #include "ostream.h"
 #include "hostpid.h"
-#include "var-expand.h"
 #include "settings.h"
 #include "master-service.h"
 #include "mail-namespace.h"
@@ -403,32 +402,41 @@ static const char *client_stats(struct client *client)
        const char *trans_id =
                smtp_server_connection_get_transaction_id(client->conn);
        const struct var_expand_table logout_tab[] = {
-               { 'i', dec2str(stats->input), "input" },
-               { 'o', dec2str(stats->output), "output" },
-               { '\0', dec2str(stats->command_count), "command_count" },
-               { '\0', dec2str(stats->reply_count), "reply_count" },
-               { '\0', trans_id, "transaction_id" },
-               { '\0', NULL, NULL }
+               { .key = "input", .value = dec2str(stats->input) },
+               { .key = "output", .value = dec2str(stats->output) },
+               { .key = "command_count", .value = dec2str(stats->command_count) },
+               { .key = "reply_count", .value = dec2str(stats->reply_count) },
+               { .key = "transaction_id", .value = trans_id },
+               VAR_EXPAND_TABLE_END
        };
-       const struct var_expand_table *user_tab =
-               mail_user_var_expand_table(client->user);
-       const struct var_expand_table *tab =
-               t_var_expand_merge_tables(logout_tab, user_tab);
+
+       const struct var_expand_params *user_params =
+               mail_user_var_expand_params(client->user);
+       const struct var_expand_params params = {
+               .tables_arr = (const struct var_expand_table*[]) {
+                       user_params->table,
+                       logout_tab,
+                       NULL
+               },
+               .providers = user_params->providers,
+               .context =  user_params->context,
+               .event = client->event,
+       };
+
        string_t *str;
        const char *error;
 
+       event_add_int(client->event, "net_in_bytes", stats->input);
+       event_add_int(client->event, "net_out_bytes", stats->output);
+
        str = t_str_new(128);
-       if (var_expand_with_funcs(str, client->set->submission_logout_format,
-                                 tab, mail_user_var_expand_func_table,
-                                 client->user, &error) <= 0) {
+       if (var_expand_new(str, client->set->submission_logout_format,
+                          &params, &error) < 0) {
                e_error(client->event,
                        "Failed to expand submission_logout_format=%s: %s",
                        client->set->submission_logout_format, error);
        }
 
-       event_add_int(client->event, "net_in_bytes", stats->input);
-       event_add_int(client->event, "net_out_bytes", stats->output);
-
        return str_c(str);
 }
 
index 58077c19cbe3dfbea42e17bd4a9fcd642cb1a2ef..988914e2783fdb39aa2cdb95e51566a5d1c50da1 100644 (file)
@@ -109,7 +109,7 @@ static const struct submission_settings submission_default_settings = {
        .submission_max_mail_size = 40*1024*1024,
        .submission_max_recipients = 0,
        .submission_client_workarounds = ARRAY_INIT,
-       .submission_logout_format = "in=%i out=%o",
+       .submission_logout_format = "in=%{input} out=%{output}",
        .submission_add_received_header = TRUE,
 
        .submission_backend_capabilities = ARRAY_INIT,