|
|
@@ -67,23 +67,31 @@ def send_ntfy_notification(backends: List[str], message: str, title: str = None)
|
|
|
try:
|
|
|
# Import ntfy here to avoid import issues during startup
|
|
|
import ntfy
|
|
|
+ from ntfy.config import load_config
|
|
|
|
|
|
# Load the ntfy config file
|
|
|
- ntfy_config = ntfy.config.load_config(config.ntfy_config_path)
|
|
|
+ ntfy_config = load_config(config.ntfy_config_path)
|
|
|
+
|
|
|
+ ntfy_config["backends"] = [backend]
|
|
|
|
|
|
# Send notification using the backend name from our config file
|
|
|
if title:
|
|
|
- ntfy.notify(message, title=title, backend=backend, config=ntfy_config)
|
|
|
+ ret = ntfy.notify(message, title=title, config=ntfy_config)
|
|
|
else:
|
|
|
- ntfy.notify(message, backend=backend, config=ntfy_config)
|
|
|
+ ret = ntfy.notify(message, config=ntfy_config, title="Note")
|
|
|
|
|
|
- successful_backends.append(backend)
|
|
|
- logger.info(f"Notification sent successfully via {backend}")
|
|
|
+ if ret == 0:
|
|
|
+ successful_backends.append(backend)
|
|
|
+ logger.info(f"Notification sent successfully via {backend}")
|
|
|
+ else:
|
|
|
+ logger.error(f"Failed to send notification via {backend}")
|
|
|
+ raise Exception(f"Failed to send notification via {backend}")
|
|
|
|
|
|
except ImportError:
|
|
|
logger.error(f"ntfy package not available for backend {backend}")
|
|
|
except Exception as e:
|
|
|
logger.error(f"Failed to send notification to {backend}: {str(e)}")
|
|
|
+ raise
|
|
|
|
|
|
success = len(successful_backends) > 0
|
|
|
return success, successful_backends
|