Skip to content

Commit

Permalink
fix(notifications): fix template rendering error
Browse files Browse the repository at this point in the history
chore(notifications): print error encountered during email template rendering
  • Loading branch information
peterbitfly committed Dec 12, 2024
1 parent a3768ce commit 3718358
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
5 changes: 4 additions & 1 deletion backend/pkg/commons/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ func SendHTMLMail(to, subject string, msg types.Email, attachment []types.EmailA
log.Infof("Email Attachments will not work with SMTP server")
err = SendMailSMTP(to, body.Bytes())
} else if utils.Config.Frontend.Mail.Mailgun.PrivateKey != "" {
_ = renderer.ExecuteTemplate(&body, "layout", MailTemplate{Mail: msg, Domain: utils.Config.Frontend.SiteDomain})
err = renderer.ExecuteTemplate(&body, "layout", MailTemplate{Mail: msg, Domain: utils.Config.Frontend.SiteDomain})
if err != nil {
log.Error(err, "error rendering mail template", 0)
}
content := body.String()
err = SendMailMailgun(to, subject, content, createTextMessage(msg), attachment)
} else {
Expand Down
17 changes: 4 additions & 13 deletions backend/pkg/commons/templates/mail/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,10 @@ <h2 style="margin-top: 0; margin-bottom: 0.5rem; font-family: 'Barlow', sans-ser
<span style="font-family: Barlow; color: white;">
<span style="color: white;">bitfly explorer GmbH, FN 623067 w, CR-Court: Commercial Court Vienna</span>
<br />
{{ if .Mail.UnSubURL }}
<span>
{{ .Mail.UnSubURL }}
<span>to stop receiving notifications of this kind.</span>
</span>
{{ end }}
{{ if .Mail.SubscriptionManageURL }}
<br />
<span>
{{ .Mail.SubscriptionManageURL }}
<span>your subscriptions.</span>
</span>
{{ end }}
<span>
{{ .Mail.SubscriptionManageURL }}
<span>your subscriptions.</span>
</span>
</span>
</td>
</tr>
Expand Down

0 comments on commit 3718358

Please sign in to comment.