- Notifications
You must be signed in to change notification settings - Fork1.1k
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
a42f1081fa12712def52e1b1a4c4779260e1e6899fb55226773e07e970e23ae2f620c9fdcdf7b9c6c1050c131a534d66110a9a66abf558cba420f3751d8d33d492d090c9c485a6d4a0c4c5cb3de419431a7fec668b766f6157e086790ff33File 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;" /> | ||
Member 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.