Skip to content

Commit efbb94b

Browse files
committed
fix(mail): simplify dry-run logic
with the addition of the outgoing mails beeing BCCd to the bp-notify user the need to have the mail dry run also send it makes less sense now. Ensuring that all files exists in the proper places and that all templates can be rendered is sufficient now as a dry run option.
1 parent e9ff154 commit efbb94b

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

internal/mail/mail.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,7 @@ func (mail *Mail) Notify(notifier string, dryRun bool) error {
123123
return fmt.Errorf("failed to render mail template: %v", err)
124124
}
125125

126-
if dryRun {
127-
slog.Info(fmt.Sprintf("[mail] dry-run enabled, using <%s> instead of <%s>", mail.email, mail.lookup[notifier].email))
128-
err = mail.send(mail.lookup[notifier].subject, htmlBody, mail.email, mail.lookup[notifier].attachments, nil)
129-
}
130-
131-
if !dryRun {
132-
err = mail.send(mail.lookup[notifier].subject, htmlBody, mail.lookup[notifier].email, mail.lookup[notifier].attachments, mail.lookup[notifier].cc)
133-
}
126+
err = mail.send(mail.lookup[notifier].subject, htmlBody, mail.lookup[notifier].email, mail.lookup[notifier].attachments, mail.lookup[notifier].cc)
134127
if err != nil {
135128
return fmt.Errorf("failed to send mail notification %v", err)
136129
}
@@ -190,7 +183,12 @@ func (mail *Mail) send(subject, message, receiver string, attachments, ccs []str
190183
if err != nil {
191184
return err
192185
}
193-
slog.Info("[mail] notification sent about dataset completion", "receiver", receiver)
186+
slog.Info("sending mail", "receiver", receiver)
187+
if dryRun {
188+
slog.Info("dry run enabled, no mail sent")
189+
return nil
190+
}
191+
194192
return client.DialAndSend(m)
195193
}
196194

0 commit comments

Comments
 (0)