Browse Source

default apprise notify type per borgmatic state

Pim Kunis 1 năm trước cách đây
mục cha
commit
86011c8418
1 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 12 1
      borgmatic/hooks/apprise.py

+ 12 - 1
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