From ab9c940d01c2a054215cb92ba52055d140f22524 Mon Sep 17 00:00:00 2001 From: Douglas Maitelli Date: Sun, 27 Jul 2025 22:29:19 +0000 Subject: [PATCH 1/5] Add support for Apprise Tags --- front/php/templates/language/de_de.json | 8 ----- front/php/templates/language/en_us.json | 10 ++++++ front/plugins/_publisher_apprise/apprise.py | 10 +++++- front/plugins/_publisher_apprise/config.json | 32 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index ef4a2417..d9f75dd1 100644 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -5,14 +5,6 @@ "API_TOKEN_name": "API-Schlüssel", "API_display_name": "API", "API_icon": "", - "APPRISE_HOST_description": "Apprise host URL starting with http:// or https://. (do not forget to include /notify at the end)", - "APPRISE_HOST_name": "Apprise host URL", - "APPRISE_PAYLOAD_description": "Select the payload type sent to Apprise. For example html works well with emails, text with chat apps, such as Telegram.", - "APPRISE_PAYLOAD_name": "Payload type", - "APPRISE_SIZE_description": "The maximum size of the apprise payload as number of characters in the passed string. If above limit, it will be truncated and a (text was truncated) message is appended.", - "APPRISE_SIZE_name": "Max payload size", - "APPRISE_URL_description": "Apprise notification target URL. For example for Telegram it would be tgram://{bot_token}/{chat_id}.", - "APPRISE_URL_name": "Apprise notification URL", "About_Design": "Entworfen für:", "About_Exit": "Abmelden", "About_Title": "Netzwerksicherheitsscanner und Benachrichtigungsframework", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 37cea711..f34113c0 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -5,6 +5,16 @@ "API_TOKEN_name": "API token", "API_display_name": "API", "API_icon": "", + "APPRISE_HOST_description": "Apprise host URL starting with http:// or https://. (do not forget to include /notify at the end)", + "APPRISE_HOST_name": "Apprise host URL", + "APPRISE_PAYLOAD_description": "Select the payload type sent to Apprise. For example html works well with emails, text with chat apps, such as Telegram.", + "APPRISE_PAYLOAD_name": "Payload type", + "APPRISE_SIZE_description": "The maximum size of the apprise payload as number of characters in the passed string. If above limit, it will be truncated and a (text was truncated) message is appended.", + "APPRISE_SIZE_name": "Max payload size", + "APPRISE_TAG_description": "Apprise notification target type.", + "APPRISE_TAG_name": "Apprise notification target type", + "APPRISE_URL_description": "Apprise notification target URL. For example for Telegram it would be tgram://{bot_token}/{chat_id}.", + "APPRISE_URL_name": "Apprise notification URL", "About_Design": "Designed for:", "About_Exit": "Sign out", "About_Title": "Network security scanner & notification framework", diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index e80a4c9a..8ab047c6 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -78,7 +78,7 @@ def main(): #------------------------------------------------------------------------------- def check_config(): - if get_setting_value('APPRISE_URL') == '' or get_setting_value('APPRISE_HOST') == '': + if get_setting_value('APPRISE_HOST') == '' or get_setting_value('APPRISE_URL') == '': return False else: return True @@ -113,6 +113,14 @@ def send(html, text): "body": payloadData } + if get_setting_value('APPRISE_TARGETTYPE') == 'tag': + _json_payload = { + "tags": get_setting_value('APPRISE_URL'), + "title": "NetAlertX Notifications", + "format": get_setting_value('APPRISE_PAYLOAD'), + "body": payloadData + } + try: # try runnning a subprocess p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), get_setting_value('APPRISE_HOST')], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/front/plugins/_publisher_apprise/config.json b/front/plugins/_publisher_apprise/config.json index fb500de2..c3bc9e3d 100755 --- a/front/plugins/_publisher_apprise/config.json +++ b/front/plugins/_publisher_apprise/config.json @@ -422,6 +422,38 @@ } ] }, + { + "function": "TARGETTYPE", + "type": { + "dataType": "string", + "elements": [ + { "elementType": "select", "elementOptions": [], "transformers": [] } + ] + }, + "default_value": "url", + "options": ["url", "tag"], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Target type" + }, + { + "language_code": "es_es", + "string": "Tipo de alvo" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Select the target type sent to Apprise." + }, + { + "language_code": "es_es", + "string": "Seleccione el tipo de alvo enviada a Apprise." + } + ] + }, { "function": "URL", "type": { From 3c18540c8c04324019349854c545231fdf3011ff Mon Sep 17 00:00:00 2001 From: Douglas Maitelli Date: Sun, 27 Jul 2025 22:35:04 +0000 Subject: [PATCH 2/5] Add support for Apprise Tags --- front/plugins/_publisher_apprise/apprise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index 8ab047c6..b6cc3766 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -115,7 +115,7 @@ def send(html, text): if get_setting_value('APPRISE_TARGETTYPE') == 'tag': _json_payload = { - "tags": get_setting_value('APPRISE_URL'), + "tag": get_setting_value('APPRISE_URL'), "title": "NetAlertX Notifications", "format": get_setting_value('APPRISE_PAYLOAD'), "body": payloadData From 8fbcb07267fc8d705a7362d37d965c9939692427 Mon Sep 17 00:00:00 2001 From: Douglas Maitelli Date: Sun, 27 Jul 2025 23:09:20 +0000 Subject: [PATCH 3/5] Review comments --- front/php/templates/language/de_de.json | 8 ++++++++ front/php/templates/language/en_us.json | 10 ---------- front/plugins/_publisher_apprise/apprise.py | 12 +++--------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index d9f75dd1..ef4a2417 100644 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -5,6 +5,14 @@ "API_TOKEN_name": "API-Schlüssel", "API_display_name": "API", "API_icon": "", + "APPRISE_HOST_description": "Apprise host URL starting with http:// or https://. (do not forget to include /notify at the end)", + "APPRISE_HOST_name": "Apprise host URL", + "APPRISE_PAYLOAD_description": "Select the payload type sent to Apprise. For example html works well with emails, text with chat apps, such as Telegram.", + "APPRISE_PAYLOAD_name": "Payload type", + "APPRISE_SIZE_description": "The maximum size of the apprise payload as number of characters in the passed string. If above limit, it will be truncated and a (text was truncated) message is appended.", + "APPRISE_SIZE_name": "Max payload size", + "APPRISE_URL_description": "Apprise notification target URL. For example for Telegram it would be tgram://{bot_token}/{chat_id}.", + "APPRISE_URL_name": "Apprise notification URL", "About_Design": "Entworfen für:", "About_Exit": "Abmelden", "About_Title": "Netzwerksicherheitsscanner und Benachrichtigungsframework", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index f34113c0..37cea711 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -5,16 +5,6 @@ "API_TOKEN_name": "API token", "API_display_name": "API", "API_icon": "", - "APPRISE_HOST_description": "Apprise host URL starting with http:// or https://. (do not forget to include /notify at the end)", - "APPRISE_HOST_name": "Apprise host URL", - "APPRISE_PAYLOAD_description": "Select the payload type sent to Apprise. For example html works well with emails, text with chat apps, such as Telegram.", - "APPRISE_PAYLOAD_name": "Payload type", - "APPRISE_SIZE_description": "The maximum size of the apprise payload as number of characters in the passed string. If above limit, it will be truncated and a (text was truncated) message is appended.", - "APPRISE_SIZE_name": "Max payload size", - "APPRISE_TAG_description": "Apprise notification target type.", - "APPRISE_TAG_name": "Apprise notification target type", - "APPRISE_URL_description": "Apprise notification target URL. For example for Telegram it would be tgram://{bot_token}/{chat_id}.", - "APPRISE_URL_name": "Apprise notification URL", "About_Design": "Designed for:", "About_Exit": "Sign out", "About_Title": "Network security scanner & notification framework", diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index b6cc3766..2d4c6079 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -106,21 +106,15 @@ def send(html, text): # Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution) + target_key = "tags" if get_setting_value('APPRISE_TARGETTYPE') == 'tag' else "urls" + _json_payload = { - "urls": get_setting_value('APPRISE_URL'), + target_key: get_setting_value('APPRISE_URL'), "title": "NetAlertX Notifications", "format": get_setting_value('APPRISE_PAYLOAD'), "body": payloadData } - if get_setting_value('APPRISE_TARGETTYPE') == 'tag': - _json_payload = { - "tag": get_setting_value('APPRISE_URL'), - "title": "NetAlertX Notifications", - "format": get_setting_value('APPRISE_PAYLOAD'), - "body": payloadData - } - try: # try runnning a subprocess p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), get_setting_value('APPRISE_HOST')], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) From 41397be1bd3ead05d1b2aefe202292f5a31362f9 Mon Sep 17 00:00:00 2001 From: Douglas Maitelli Date: Sun, 27 Jul 2025 23:09:48 +0000 Subject: [PATCH 4/5] Review comments --- front/plugins/_publisher_apprise/apprise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index 2d4c6079..1ac77d7b 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -78,7 +78,7 @@ def main(): #------------------------------------------------------------------------------- def check_config(): - if get_setting_value('APPRISE_HOST') == '' or get_setting_value('APPRISE_URL') == '': + if get_setting_value('APPRISE_URL') == '' or get_setting_value('APPRISE_HOST') == '': return False else: return True From 0d6bc71d2b7544bb3f374923e544bc302120e56a Mon Sep 17 00:00:00 2001 From: Douglas Maitelli Date: Mon, 28 Jul 2025 00:29:14 +0000 Subject: [PATCH 5/5] Review comments --- front/plugins/_publisher_apprise/apprise.py | 7 +++-- front/plugins/_publisher_apprise/config.json | 32 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index 1ac77d7b..967074ed 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -78,7 +78,7 @@ def main(): #------------------------------------------------------------------------------- def check_config(): - if get_setting_value('APPRISE_URL') == '' or get_setting_value('APPRISE_HOST') == '': + if get_setting_value('APPRISE_HOST') == '' or (get_setting_value('APPRISE_URL') == '' and get_setting_value('APPRISE_TAG') == ''): return False else: return True @@ -106,10 +106,11 @@ def send(html, text): # Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution) - target_key = "tags" if get_setting_value('APPRISE_TARGETTYPE') == 'tag' else "urls" + target_key = "tag" if get_setting_value('APPRISE_TARGETTYPE') == 'tag' else "urls" + target_value = get_setting_value('APPRISE_TAG') if target_key == 'tag' else get_setting_value('APPRISE_URL') _json_payload = { - target_key: get_setting_value('APPRISE_URL'), + target_key: target_value, "title": "NetAlertX Notifications", "format": get_setting_value('APPRISE_PAYLOAD'), "body": payloadData diff --git a/front/plugins/_publisher_apprise/config.json b/front/plugins/_publisher_apprise/config.json index c3bc9e3d..7731bfbe 100755 --- a/front/plugins/_publisher_apprise/config.json +++ b/front/plugins/_publisher_apprise/config.json @@ -486,6 +486,38 @@ } ] }, + { + "function": "TAG", + "type": { + "dataType": "string", + "elements": [ + { "elementType": "input", "elementOptions": [], "transformers": [] } + ] + }, + "default_value": "", + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Apprise notification tag" + }, + { + "language_code": "es_es", + "string": "Tag de notificación de Apprise" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Apprise notification target tag." + }, + { + "language_code": "es_es", + "string": "Informar de la tag de destino de la notificación." + } + ] + }, { "function": "PAYLOAD", "type": {