Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e46638

Browse files
committed
feat(notifications): add company logo url when available for email notifications
1 parentd0a8424 commit4e46638

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

‎coderd/database/models.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/querier.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/notifications/dispatch/smtp/html.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<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;">
99
<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;">
1010
<div style="text-align: center;">
11-
<img src="https://coder.com/coder-logo-horizontal.png" alt="Coder Logo" style="height: 40px;" />
11+
<img src="{{ .Labels._logo_url }}" alt="Company Logo" style="height: 40px;" />
1212
</div>
1313
<h1 style="text-align: center; font-size: 24px; font-weight: 400; margin: 8px 0 32px; line-height: 1.5;">
1414
{{ .Labels._subject }}

‎coderd/notifications/notifier.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package notifications
22

33
import (
44
"context"
5+
"database/sql"
56
"encoding/json"
7+
"errors"
68
"sync"
79
"text/template"
810

@@ -22,6 +24,10 @@ import (
2224
"github.com/coder/coder/v2/coderd/database"
2325
)
2426

27+
const (
28+
notificationsDefaultLogoURL="https://coder.com/coder-logo-horizontal.png"
29+
)
30+
2531
// notifier is a consumer of the notifications_messages queue. It dequeues messages from that table and processes them
2632
// through a pipeline of fetch -> prepare -> render -> acquire handler -> deliver.
2733
typenotifierstruct {
@@ -223,6 +229,18 @@ func (n *notifier) prepare(ctx context.Context, msg database.AcquireNotification
223229
returnnil,xerrors.Errorf("failed to resolve handler %q",msg.Method)
224230
}
225231

232+
logoURL,err:=n.store.GetLogoURL(ctx)
233+
iferr!=nil&&!errors.Is(err,sql.ErrNoRows) {
234+
n.log.Error(ctx,"failed fetching logo url",slog.Error(err))
235+
}
236+
237+
iflogoURL=="" {
238+
//nolint:ineffassign // define to default value if unable to fetch one from db
239+
logoURL=notificationsDefaultLogoURL
240+
}
241+
242+
payload.Labels["_logo_url"]=logoURL
243+
226244
vartitle,bodystring
227245
iftitle,err=render.GoTemplate(msg.TitleTemplate,payload,n.helpers);err!=nil {
228246
returnnil,xerrors.Errorf("render title: %w",err)

‎coderd/notifications/spec.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type Store interface {
2222
FetchNewMessageMetadata(ctx context.Context,arg database.FetchNewMessageMetadataParams) (database.FetchNewMessageMetadataRow,error)
2323
GetNotificationMessagesByStatus(ctx context.Context,arg database.GetNotificationMessagesByStatusParams) ([]database.NotificationMessage,error)
2424
GetNotificationsSettings(ctx context.Context) (string,error)
25+
26+
GetLogoURL(ctx context.Context) (string,error)
2527
}
2628

2729
// Handler is responsible for preparing and delivering a notification by a given method.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp