From 360bb6f30603f9bf3104e3fdc575159cc7729805 Mon Sep 17 00:00:00 2001 From: bluewalk Date: Sun, 20 Nov 2022 10:42:44 +0100 Subject: [PATCH] Split name and address for TO-variables --- data/conf/rspamd/meta_exporter/pushover.php | 21 ++++++++++++++++----- data/web/templates/edit/mailbox.twig | 2 +- data/web/templates/user/Pushover.twig | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/data/conf/rspamd/meta_exporter/pushover.php b/data/conf/rspamd/meta_exporter/pushover.php index 2f2206ea..4c8092d1 100644 --- a/data/conf/rspamd/meta_exporter/pushover.php +++ b/data/conf/rspamd/meta_exporter/pushover.php @@ -55,7 +55,6 @@ $sender = $headers['X-Rspamd-From']; $ip = $headers['X-Rspamd-Ip']; $subject = $headers['X-Rspamd-Subject']; $priority = 0; -$to = $json_body->header_to[0]; $symbols_array = json_decode($headers['X-Rspamd-Symbols'], true); if (is_array($symbols_array)) { @@ -69,10 +68,16 @@ if (is_array($symbols_array)) { $sender_address = $json_body->header_from[0]; $sender_name = '-'; - if (preg_match('/(?.*?)<(?
.*?)>/i', $sender_address, $matches)) { $sender_address = $matches['address']; - $sender_name = trim(trim($matches['name']), '"\' '); + $sender_name = trim($matches['name'], '"\' '); +} + +$to_address = $json_body->header_to[0]; +$to_name = '-'; +if (preg_match('/(?.*?)<(?
.*?)>/i', $to_address, $matches)) { + $to_address = $matches['address']; + $to_name = trim($matches['name'], '"\' '); } $rcpt_final_mailboxes = array(); @@ -239,9 +244,15 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) { $post_fields = array( "token" => $api_data['token'], "user" => $api_data['key'], - "title" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO}'), array($subject, $sender, $sender_name, $sender_address, $to), $title)), + "title" => sprintf("%s", str_replace( + array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO_NAME}', '{TO_ADDRESS}'), + array($subject, $sender, $sender_name, $sender_address, $to_name, $to_address), $title) + ), "priority" => $priority, - "message" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO}', '\n'), array($subject, $sender, $sender_name, $sender_address, $to, PHP_EOL), $text)), + "message" => sprintf("%s", str_replace( + array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO_NAME}', '{TO_ADDRESS}', '\n'), + array($subject, $sender, $sender_name, $sender_address, $to_name, $to_address, PHP_EOL), $text) + ), "sound" => $attributes['sound'] ?? "pushover" ); if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) { diff --git a/data/web/templates/edit/mailbox.twig b/data/web/templates/edit/mailbox.twig index f2e80c96..9eb7c951 100644 --- a/data/web/templates/edit/mailbox.twig +++ b/data/web/templates/edit/mailbox.twig @@ -275,7 +275,7 @@

{{ lang.user.pushover_info|format(mailbox)|raw }}

-

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO}

+

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO_NAME}, {TO_ADDRESS}

diff --git a/data/web/templates/user/Pushover.twig b/data/web/templates/user/Pushover.twig index ea1d2c16..5bd6b1a4 100644 --- a/data/web/templates/user/Pushover.twig +++ b/data/web/templates/user/Pushover.twig @@ -9,7 +9,7 @@

{{ lang.user.pushover_info|format(mailcow_cc_username)|raw }}

-

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO}

+

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO_NAME}, {TO_ADDRESS}