From 86011c841807238305f011ddb98a27871cb6ed24 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Thu, 21 Sep 2023 22:02:45 +0200 Subject: [PATCH] default apprise notify type per borgmatic state --- borgmatic/hooks/apprise.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/borgmatic/hooks/apprise.py b/borgmatic/hooks/apprise.py index dbb4e47..53f46c9 100644 --- a/borgmatic/hooks/apprise.py +++ b/borgmatic/hooks/apprise.py @@ -31,7 +31,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev { 'title': f'A borgmatic {state.name} event happened', 'body': f'A borgmatic {state.name} event happened', - 'notification_type': 'success', # TODO: default per state.name + 'notification_type': default_notify_type(state.name.lower()), # 'tag': ['borgmatic'], }, ) @@ -74,6 +74,17 @@ def get_notify_type(s): return NotifyType.FAILURE +def default_notify_type(state): + if state == 'start': + return NotifyType.INFO + if state == 'finish': + return NotifyType.SUCCESS + if state == 'fail': + return NotifyType.FAILURE + if state == 'log': + return NotifyType.INFO + + def destroy_monitor( ping_url_or_uuid, config, config_filename, monitoring_log_level, dry_run ): # pragma: no cover