Add support for notification dry run feature

- Introduced NOTIFICATION_DRY_RUN configuration option in .env.example and k8s/secret.example.yaml.
- Updated README.md to include usage instructions for the new dry run feature.
- Implemented logic in app.go to preview notifications without sending them when the dry run option is enabled.
- Enhanced config.go to load the new configuration option and validate notification types accordingly.
- Added a new function in notify.go to generate manual-needed notification messages for preview.
This commit is contained in:
Zsolt Alföldi
2026-05-07 00:35:05 +02:00
parent 469e5b0678
commit ecea084003
8 changed files with 92 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ DRY_RUN='false'
ALERT_AFTER='48h'
# Optional notifications: set NOTIFICATION_TYPE to 'ntfy' or 'smtp'.
NOTIFICATION_DRY_RUN='false'
NOTIFICATION_TYPE=''
NOTIFICATION_NTFY_URL=''
@@ -33,6 +34,8 @@ NOTIFICATION_SMTP_TO=''
`DRY_RUN=false` is the default and will call qBittorrent `setForceStart` and `reannounce`. Use `--dry-run=true` when you only want to preview matches.
Use `--notification-dry-run=true` to print the manual-needed notification subject/body without sending it.
Set `NOTIFICATION_TYPE=ntfy` and `NOTIFICATION_NTFY_URL='https://ntfy.sh/your-secret-topic'` to send manual-needed alerts through ntfy. For compatibility, old `NOTIFY_URL` values still work as the ntfy URL.
Set `NOTIFICATION_TYPE=smtp` to send manual-needed alerts by email. For Gmail, use:
@@ -58,6 +61,12 @@ Preview without qBittorrent actions:
go run ./cmd/ncore-hnr --dry-run=true
```
Preview the notification body without sending it:
```bash
go run ./cmd/ncore-hnr --dry-run=true --alert-after=0s --notification-dry-run=true
```
JSON output:
```bash