From e5b76ca49ec37438b8de2b58796ff192b3783ccb Mon Sep 17 00:00:00 2001 From: wienfuchs <44177781+wienfuchs@users.noreply.github.com> Date: Thu, 15 Apr 2021 01:50:44 +0200 Subject: [PATCH] add feature "add url" to email and telegram (#1085) Resolved #967. * add feature "add url" to email and telegram * Added missing brackets * Changed $body to correct var $message And changed PHP_EOL to
. * Changed text a little * Add dutch translation Co-authored-by: TimZ99 --- src/lang/de_DE.lang.php | 5 +++++ src/lang/en_US.lang.php | 2 ++ src/lang/nl_NL.lang.php | 2 ++ src/psm/Module/Config/Controller/ConfigController.php | 4 ++++ src/psm/Util/Install/Installer.php | 2 ++ src/psm/Util/Server/Updater/StatusNotifier.php | 4 +++- src/templates/default/module/config/config.tpl.html | 4 ++++ 7 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index ae0a7313..2d711bd2 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -196,6 +196,7 @@ $sm_lang = array( 'general' => 'Allgemein', 'language' => 'Sprache', 'show_update' => 'Wöchentlich auf Aktualisierungen prüfen?', + 'email_add_url' => 'Server URL an E-Mail anhängen?', 'email_status' => 'E-Mail-Versand erlauben?', 'email_from_email' => 'Absenderadresse', 'email_from_name' => 'Name des Absenders', @@ -221,6 +222,9 @@ $sm_lang = array( 'pushover_api_token_description' => 'Bevor Sie Pushover verwenden können, müssen Sie Ihre Anwendung hier registrieren und Ihren Anwendungs-API-Token hier eingeben.', + 'telegram_status' => 'Telegram Nachrichten erlauben?', + 'telegram_add_url' => 'Server URL an Nachricht anhängen?', + 'jabber_status' => 'Allow sending Jabber (XMPP) messages', 'alert_type' => 'Wann möchten Sie benachrichtigt werden?', 'alert_type_description' => 'Status geändert: ... wenn sich der Status ändert
z. B. online -> offline oder offline -> online.

Offline: Sie bekommen eine @@ -237,6 +241,7 @@ $sm_lang = array( 'log_email' => 'E-Mail-Versand protokollieren?', 'log_sms' => 'SMS-Versand protokollieren?', 'log_pushover' => 'Pushover-Versand protokollieren?', + 'log_telegram' => 'Telegram-Versand protokollieren?', 'updated' => 'Die Einstellungen wurden gespeichert.', 'tab_email' => 'E-Mail', 'tab_sms' => 'SMS', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 0d64ce17..ba697d5b 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -297,6 +297,7 @@ $sm_lang = array( 'proxy_user' => 'Proxy username', 'proxy_password' => 'Proxy password', 'email_status' => 'Allow sending email', + 'email_add_url' => 'Add url to the monitor in email', 'email_from_email' => 'Email from address', 'email_from_name' => 'Email from name', 'email_smtp' => 'Enable SMTP', @@ -326,6 +327,7 @@ $sm_lang = array( 'pushover_api_token' => 'Pushover App API Token', 'pushover_api_token_description' => 'Before you can use Pushover, you need to register an App at their website and enter the App API Token here.', 'telegram_status' => 'Allow sending Telegram messages', + 'telegram_add_url' => 'Add url to the monitor in the message', 'telegram_description' => 'Telegram is a chat app that makes it easy to get real-time notifications. Visit the documentation for more info and an install guide.', 'telegram_api_token' => 'Telegram API Token', 'telegram_api_token_description' => 'Before you can use Telegram, you need to get a API token. Visit the documentation for help.', diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index a5a1c728..7179bbcf 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -250,6 +250,7 @@ $sm_lang = array( 'language' => 'Taal', 'show_update' => 'Controleer wekelijks voor updates?', 'email_status' => 'Sta email berichten toe?', + 'email_add_url' => 'Voeg url van de monitor toe aan de email', 'email_from_email' => 'Email van adres', 'email_from_name' => 'Email van naam', 'email_smtp' => 'SMTP gebruiken', @@ -275,6 +276,7 @@ $sm_lang = array( target="_blank" rel="noopener">App registreren via hun website, en daarvan de App API Token hier invullen.', 'telegram_status' => 'Sta Telegram berichten toe?', + 'telegram_add_url' => 'voeg url van de monitor toe aan het bericht', 'telegram_api_token' => 'Telegram API Token', 'alert_type' => 'Selecteer wanneer je een notificatie wilt', 'alert_type_description' => 'Status verandert: Je ontvangt alleen bericht wanneer een server van status diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index c93ca375..5285ea70 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -41,12 +41,14 @@ class ConfigController extends AbstractController protected $checkboxes = array( 'proxy', 'email_status', + 'email_add_url', 'email_smtp', 'sms_status', 'discord_status', 'pushover_status', 'webhook_status', 'telegram_status', + 'telegram_add_url', 'jabber_status', 'log_status', 'log_email', @@ -602,6 +604,7 @@ class ConfigController extends AbstractController 'label_proxy_url' => psm_get_lang('config', 'proxy_url'), 'label_proxy_user' => psm_get_lang('config', 'proxy_user'), 'label_proxy_password' => psm_get_lang('config', 'proxy_password'), + 'label_email_add_url' => psm_get_lang('config', 'email_add_url'), 'label_email_status' => psm_get_lang('config', 'email_status'), 'label_email_from_email' => psm_get_lang('config', 'email_from_email'), 'label_email_from_name' => psm_get_lang('config', 'email_from_name'), @@ -636,6 +639,7 @@ class ConfigController extends AbstractController ), 'label_telegram_description' => psm_get_lang('config', 'telegram_description'), 'label_telegram_status' => psm_get_lang('config', 'telegram_status'), + 'label_telegram_add_url' => psm_get_lang('config', 'telegram_add_url'), 'label_telegram_api_token' => psm_get_lang('config', 'telegram_api_token'), 'label_telegram_api_token_description' => psm_get_lang('config', 'telegram_api_token_description'), 'label_jabber_status' => psm_get_lang('config', 'jabber_status'), diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index ab9e5fef..c15b0322 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -147,6 +147,7 @@ class Installer ('proxy_user', ''), ('proxy_password', ''), ('email_status', '1'), + ('email_add_url', '0'), ('email_from_email', 'monitor@example.org'), ('email_from_name', 'Server Monitor'), ('email_smtp', ''), @@ -164,6 +165,7 @@ class Installer ('pushover_status', '0'), ('pushover_api_token', ''), ('telegram_status', '0'), + ('telegram_add_url', '0'), ('telegram_api_token', ''), ('jabber_status', '1'), ('jabber_host', ''), diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index dd145db7..970bc714 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -426,7 +426,8 @@ class StatusNotifier $body = key_exists('message', $combi) ? $combi['message'] : - psm_parse_msg($this->status_new, 'email_body', $this->server); + psm_parse_msg($this->status_new, 'email_body', $this->server); + if ((bool)psm_get_conf('email_add_url')) $body .= PHP_EOL.PHP_EOL.''.PSM_BASE_URL.''; $mail->Body = $body; $mail->AltBody = str_replace('
', "\n", $body); @@ -695,6 +696,7 @@ class StatusNotifier $message = key_exists('message', $combi) ? $combi['message'] : psm_parse_msg($this->status_new, 'telegram_message', $this->server); + if ((bool)psm_get_conf('telegram_add_url')) $message .= '
'.PSM_BASE_URL; $telegram = psm_build_telegram(); $telegram->setMessage($message); diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index db5ab029..56fd86b7 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -142,6 +142,8 @@ {{ macro.input_checkbox("email_status", "email_status[]", label_email_status, email_status_checked) }} {{ macro.input_checkbox("log_email", "log_email[]", label_log_email, log_email_checked) }} + + {{ macro.input_checkbox("email_add_url", "email_add_url[]", label_email_add_url, email_add_url_checked) }} {{ macro.input_field("text", "email_from_name", null, "email_from_name", label_email_from_name, email_from_name, label_email_from_name, "255") }} @@ -222,6 +224,8 @@ {{ macro.input_checkbox("telegram_status", "telegram_status[]", label_telegram_status, telegram_status_checked) }} {{ macro.input_checkbox("log_telegram", "log_telegram[]", label_log_telegram, log_telegram_checked) }} + + {{ macro.input_checkbox("telegram_add_url", "telegram_add_url[]", label_telegram_add_url, telegram_add_url_checked) }} {{ macro.input_field("text", "telegram_api_token", null, "telegram_api_token", label_telegram_api_token, telegram_api_token, label_telegram_api_token, "255", "telegram_api_token_help", label_telegram_api_token_description) }} {{ macro.button_test("testTelegram", label_test) }}