diff --git a/borgmatic/hooks/monitoring/ntfy.py b/borgmatic/hooks/monitoring/ntfy.py index 0429e703..50b31744 100644 --- a/borgmatic/hooks/monitoring/ntfy.py +++ b/borgmatic/hooks/monitoring/ntfy.py @@ -22,6 +22,12 @@ def initialize_monitor( ''' +def _convert_string_to_array(value): + value = str(value or '') + + return [str(item).strip() for item in value.split(',') if str(item).strip()] + + PRIORITY_NAME_TO_ID = { 'max': 5, 'urgent': 5, @@ -66,7 +72,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev 'title': state_config.get('title'), 'message': state_config.get('message'), 'priority': PRIORITY_NAME_TO_ID.get(state_config.get('priority'), default_priority), - 'tags': state_config.get('tags'), + 'tags': _convert_string_to_array(state_config.get('tags')), } try: diff --git a/tests/unit/hooks/monitoring/test_ntfy.py b/tests/unit/hooks/monitoring/test_ntfy.py index 7588edd6..6280785a 100644 --- a/tests/unit/hooks/monitoring/test_ntfy.py +++ b/tests/unit/hooks/monitoring/test_ntfy.py @@ -25,7 +25,7 @@ CUSTOM_MESSAGE_PAYLOAD = { 'title': CUSTOM_MESSAGE_CONFIG['title'], 'message': CUSTOM_MESSAGE_CONFIG['message'], 'priority': 1, - 'tags': CUSTOM_MESSAGE_CONFIG['tags'], + 'tags': [CUSTOM_MESSAGE_CONFIG['tags']], } @@ -35,7 +35,7 @@ def default_message_payload(state=Enum): 'title': f'A borgmatic {state.name} event happened', 'message': f'A borgmatic {state.name} event happened', 'priority': 3, - 'tags': 'borgmatic', + 'tags': ['borgmatic'], }