|
@@ -68,26 +68,17 @@ def send_ntfy_notification(backends: List[str], message: str, title: str = None)
|
|
|
# Import ntfy here to avoid import issues during startup
|
|
# Import ntfy here to avoid import issues during startup
|
|
|
import ntfy
|
|
import ntfy
|
|
|
|
|
|
|
|
- # Set the ntfy config file path
|
|
|
|
|
- old_config = os.environ.get('NTFY_CONFIG')
|
|
|
|
|
- os.environ['NTFY_CONFIG'] = config.ntfy_config_path
|
|
|
|
|
|
|
+ # Load the ntfy config file
|
|
|
|
|
+ ntfy_config = ntfy.load_config(config.ntfy_config_path)
|
|
|
|
|
|
|
|
- try:
|
|
|
|
|
- # Send notification using the backend name from our config file
|
|
|
|
|
- if title:
|
|
|
|
|
- ntfy.notify(message, title=title, backend=backend)
|
|
|
|
|
- else:
|
|
|
|
|
- ntfy.notify(message, backend=backend)
|
|
|
|
|
-
|
|
|
|
|
- successful_backends.append(backend)
|
|
|
|
|
- logger.info(f"Notification sent successfully via {backend}")
|
|
|
|
|
-
|
|
|
|
|
- finally:
|
|
|
|
|
- # Restore original config
|
|
|
|
|
- if old_config:
|
|
|
|
|
- os.environ['NTFY_CONFIG'] = old_config
|
|
|
|
|
- elif 'NTFY_CONFIG' in os.environ:
|
|
|
|
|
- del os.environ['NTFY_CONFIG']
|
|
|
|
|
|
|
+ # Send notification using the backend name from our config file
|
|
|
|
|
+ if title:
|
|
|
|
|
+ ntfy.notify(message, title=title, backend=backend, config=ntfy_config)
|
|
|
|
|
+ else:
|
|
|
|
|
+ ntfy.notify(message, backend=backend, config=ntfy_config)
|
|
|
|
|
+
|
|
|
|
|
+ successful_backends.append(backend)
|
|
|
|
|
+ logger.info(f"Notification sent successfully via {backend}")
|
|
|
|
|
|
|
|
except ImportError:
|
|
except ImportError:
|
|
|
logger.error(f"ntfy package not available for backend {backend}")
|
|
logger.error(f"ntfy package not available for backend {backend}")
|