- Notifications
You must be signed in to change notification settings - Fork929
feat(coderd): add company logo when available for email notifications#14935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
a42f108
1fa1271
2def52e
1b1a4c4
779260e
1e6899f
b552267
73e07e9
70e23ae
2f620c9
fdcdf7b
9c6c105
0c131a5
34d6611
0a9a66a
bf558cb
a420f37
51d8d33
d492d09
0c9c485
a6d4a0c
4c5cb3d
e419431
a7fec66
8b766f6
157e086
790ff33
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
…cher function
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -55,15 +55,13 @@ type SMTPHandler struct { | ||
noAuthWarnOnce sync.Once | ||
loginWarnOnce sync.Once | ||
} | ||
func NewSMTPHandler(cfg codersdk.NotificationsEmailConfig, log slog.Logger) *SMTPHandler { | ||
return &SMTPHandler{cfg: cfg, log: log} | ||
} | ||
func (s *SMTPHandler) Dispatcher(helpers template.FuncMap,payload types.MessagePayload, titleTmpl, bodyTmpl string) (DeliveryFunc, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Nit: when passing arguments, I try think of them in order of significance. | ||
// First render the subject & body into their own discrete strings. | ||
subject, err := markdown.PlaintextFromMarkdown(titleTmpl) | ||
if err != nil { | ||
@@ -79,12 +77,12 @@ func (s *SMTPHandler) Dispatcher(payload types.MessagePayload, titleTmpl, bodyTm | ||
// Then, reuse these strings in the HTML & plain body templates. | ||
payload.Labels["_subject"] = subject | ||
payload.Labels["_body"] = htmlBody | ||
htmlBody, err = render.GoTemplate(htmlTemplate, payload, helpers) | ||
if err != nil { | ||
return nil, xerrors.Errorf("render full html template: %w", err) | ||
} | ||
payload.Labels["_body"] = plainBody | ||
plainBody, err = render.GoTemplate(plainTemplate, payload, helpers) | ||
if err != nil { | ||
return nil, xerrors.Errorf("render full plaintext template: %w", err) | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dispatch_test | ||
var ( | ||
helpers = map[string]any{ | ||
"base_url": func() string { return "http://test.com" }, | ||
"current_year": func() string { return "2024" }, | ||
"logo_url": func() string { return "https://coder.com/coder-logo-horizontal.png" }, | ||
"app_name": func() string { return "Coder" }, | ||
} | ||
) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.