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

Commitef62e62

Browse files
fix: ensure targets are propagated to inbox (#16985)
Currently the `targets` column in `inbox_notifications` doesn't getfilled. This PR fixes that. Rather than give targets special treatment,we should put it in the payload like everything else. This correctlypropagates notification targets to the inbox table without much codechange.
1 parent995e940 commitef62e62

File tree

27 files changed

+38
-36
lines changed

27 files changed

+38
-36
lines changed

‎coderd/database/queries.sql.go‎

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/notifications.sql‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ SELECT
8484
nm.method,
8585
nm.attempt_count::intAS attempt_count,
8686
nm.queued_seconds::floatAS queued_seconds,
87-
nm.targets,
8887
-- template
8988
nt.idAS template_id,
9089
nt.title_template,

‎coderd/notifications/enqueuer.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (s *StoreEnqueuer) EnqueueWithData(ctx context.Context, userID, templateID
7474
dispatchMethod=metadata.CustomMethod.NotificationMethod
7575
}
7676

77-
payload,err:=s.buildPayload(metadata,labels,data)
77+
payload,err:=s.buildPayload(metadata,labels,data,targets)
7878
iferr!=nil {
7979
s.log.Warn(ctx,"failed to build payload",slog.F("template_id",templateID),slog.F("user_id",userID),slog.Error(err))
8080
returnnil,xerrors.Errorf("enqueue notification (payload build): %w",err)
@@ -132,9 +132,9 @@ func (s *StoreEnqueuer) EnqueueWithData(ctx context.Context, userID, templateID
132132
// buildPayload creates the payload that the notification will for variable substitution and/or routing.
133133
// The payload contains information about the recipient, the event that triggered the notification, and any subsequent
134134
// actions which can be taken by the recipient.
135-
func (s*StoreEnqueuer)buildPayload(metadata database.FetchNewMessageMetadataRow,labelsmap[string]string,datamap[string]any) (*types.MessagePayload,error) {
135+
func (s*StoreEnqueuer)buildPayload(metadata database.FetchNewMessageMetadataRow,labelsmap[string]string,datamap[string]any,targets []uuid.UUID) (*types.MessagePayload,error) {
136136
payload:= types.MessagePayload{
137-
Version:"1.1",
137+
Version:"1.2",
138138

139139
NotificationName:metadata.NotificationName,
140140
NotificationTemplateID:metadata.NotificationTemplateID.String(),
@@ -144,8 +144,9 @@ func (s *StoreEnqueuer) buildPayload(metadata database.FetchNewMessageMetadataRo
144144
UserName:metadata.UserName,
145145
UserUsername:metadata.UserUsername,
146146

147-
Labels:labels,
148-
Data:data,
147+
Labels:labels,
148+
Data:data,
149+
Targets:targets,
149150

150151
// No actions yet
151152
}

‎coderd/notifications/notifications_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,6 @@ func TestNotificationTemplates_Golden(t *testing.T) {
13331333
)
13341334
require.NoError(t,err)
13351335

1336-
tc.payload.Targets=append(tc.payload.Targets,user.ID)
13371336
_,err=smtpEnqueuer.EnqueueWithData(
13381337
ctx,
13391338
user.ID,
@@ -1466,7 +1465,7 @@ func TestNotificationTemplates_Golden(t *testing.T) {
14661465
tc.payload.Labels,
14671466
tc.payload.Data,
14681467
user.Username,
1469-
user.ID,
1468+
tc.payload.Targets...,
14701469
)
14711470
require.NoError(t,err)
14721471

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateTemplateDeleted.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "Template Deleted",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateTemplateDeprecated.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "Template Deprecated",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateTestNotification.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "Test Notification",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateUserAccountActivated.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "User account activated",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateUserAccountCreated.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "User account created",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateUserAccountDeleted.json.golden‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"_version": "1.1",
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
5-
"_version": "1.1",
5+
"_version": "1.2",
66
"notification_name": "User account deleted",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp