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

@@ -122,6 +122,11 @@ func Run(cfg config.Config) (model.RunSummary, error) {
return summary, err
}
if cfg.NotificationDryRun {
printNotificationPreview(cfg.NotificationType, summary.Results)
return summary, nil
}
notifier := newNotifier(cfg)
if notifier != nil {
if err := notifier.SendManualNeeded(summary.Results); err != nil {
@@ -300,3 +305,17 @@ func newNotifier(cfg config.Config) notify.Sender {
return nil
}
}
func printNotificationPreview(notificationType string, results []model.ActionResult) {
subject, body, ok := notify.ManualNeededMessage(results)
if !ok {
fmt.Fprintln(os.Stderr, "notification dry-run: no manual-needed torrents, nothing would be sent")
return
}
if notificationType == "" {
notificationType = "unconfigured"
}
fmt.Fprintf(os.Stderr, "notification dry-run: type=%s\n", notificationType)
fmt.Fprintf(os.Stderr, "Subject: %s\n\n%s", subject, body)
}