diff --git a/main.go b/main.go index 6c7e07d..d095bcf 100644 --- a/main.go +++ b/main.go @@ -45,7 +45,7 @@ iplant_groups: const warningSentKey = "warningsent" const oneDayWarningKey = "onedaywarning" -func sendNotif(ctx context.Context, j *Job, status, subject, msg, email_template string) error { +func sendNotif(ctx context.Context, j *Job, status, subject, msg string, email bool, email_template string) error { var err error // Don't send notification if things aren't configured correctly. It's @@ -80,10 +80,12 @@ func sendNotif(ctx context.Context, j *Job, status, subject, msg, email_template p.AnalysisStartDate = strconv.FormatInt(sdmillis, 10) p.AnalysisResultsFolder = j.ResultFolder p.RunDuration = durString - p.Email = user.Email + if email { + p.Email = user.Email + } p.User = u - notif := NewNotification(u, subject, msg, true, email_template, p) + notif := NewNotification(u, subject, msg, email, email_template, p) resp, err := notif.Send(ctx) if err != nil { @@ -143,7 +145,7 @@ func SendKillNotification(ctx context.Context, j *Job, killNotifKey string) erro endtime.UTC().Format(time.UnixDate), j.ResultFolder, ) - err = sendNotif(ctx, j, "Canceled", subject, msg, "analysis_status_change") + err = sendNotif(ctx, j, "Canceled", subject, msg, true, "analysis_status_change") return err } @@ -167,7 +169,7 @@ func SendWarningNotification(ctx context.Context, j *Job) error { j.ResultFolder, ) - return sendNotif(ctx, j, j.Status, subject, msg, "analysis_status_change") + return sendNotif(ctx, j, j.Status, subject, msg, true, "analysis_status_change") } func SendPeriodicNotification(ctx context.Context, j *Job) error { @@ -186,7 +188,7 @@ func SendPeriodicNotification(ctx context.Context, j *Job) error { durString, ) - return sendNotif(ctx, j, j.Status, subject, msg, "analysis_periodic_notification") + return sendNotif(ctx, j, j.Status, subject, msg, j.NotifyPeriodic, "analysis_periodic_notification") } func ensureNotifRecord(ctx context.Context, vicedb *VICEDatabaser, job Job) error {