- Notifications
You must be signed in to change notification settings - Fork927
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 fromall commits
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
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,7 +8,7 @@ | ||
<body style="margin: 0; padding: 0; font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; color: #020617; background: #f8fafc;"> | ||
<div style="max-width: 600px; margin: 20px auto; padding: 60px; border: 1px solid #e2e8f0; border-radius: 8px; background-color: #fff; text-align: left; font-size: 14px; line-height: 1.5;"> | ||
<div style="text-align: center;"> | ||
<img src="{{ logo_url }}" alt="{{ app_name }} Logo" style="height: 40px;" /> | ||
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. note: my immediate thought was to use aData URL but apparently support for this is extremely limited. | ||
</div> | ||
<h1 style="text-align: center; font-size: 24px; font-weight: 400; margin: 8px 0 32px; line-height: 1.5;"> | ||
{{ .Labels._subject }} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dispatch_test | ||
func helpers() map[string]any { | ||
return 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" }, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package notifications | ||
import ( | ||
"context" | ||
"database/sql" | ||
"errors" | ||
"text/template" | ||
"golang.org/x/xerrors" | ||
"cdr.dev/slog" | ||
) | ||
func (n *notifier) fetchHelpers(ctx context.Context) (map[string]any, error) { | ||
appName, err := n.fetchAppName(ctx) | ||
if err != nil { | ||
n.log.Error(ctx, "failed to fetch app name", slog.Error(err)) | ||
return nil, xerrors.Errorf("fetch app name: %w", err) | ||
} | ||
logoURL, err := n.fetchLogoURL(ctx) | ||
if err != nil { | ||
n.log.Error(ctx, "failed to fetch logo URL", slog.Error(err)) | ||
return nil, xerrors.Errorf("fetch logo URL: %w", err) | ||
} | ||
helpers := make(template.FuncMap) | ||
for k, v := range n.helpers { | ||
helpers[k] = v | ||
} | ||
helpers["app_name"] = func() string { return appName } | ||
helpers["logo_url"] = func() string { return logoURL } | ||
return helpers, nil | ||
} | ||
func (n *notifier) fetchAppName(ctx context.Context) (string, error) { | ||
appName, err := n.store.GetApplicationName(ctx) | ||
if err != nil { | ||
if errors.Is(err, sql.ErrNoRows) { | ||
return notificationsDefaultAppName, nil | ||
} | ||
return "", xerrors.Errorf("get application name: %w", err) | ||
} | ||
return appName, nil | ||
} | ||
func (n *notifier) fetchLogoURL(ctx context.Context) (string, error) { | ||
logoURL, err := n.store.GetLogoURL(ctx) | ||
if err != nil { | ||
if errors.Is(err, sql.ErrNoRows) { | ||
return notificationsDefaultLogoURL, nil | ||
} | ||
return "", xerrors.Errorf("get logo URL: %w", err) | ||
} | ||
return logoURL, nil | ||
} |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.