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",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateUserAccountSuspended.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 suspended",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateUserRequestedOneTimePasscode.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": "One-Time Passcode",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceAutoUpdated.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": "Workspace Updated Automatically",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

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

Lines changed: 5 additions & 2 deletions
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": "Workspace Autobuild Failed",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",
@@ -20,7 +20,10 @@
2020
"reason": "autostart"
2121
},
2222
"data": null,
23-
"targets": null
23+
"targets": [
24+
"00000000-0000-0000-0000-000000000000",
25+
"00000000-0000-0000-0000-000000000000"
26+
]
2427
},
2528
"title": "Workspace \"bobby-workspace\" autobuild failed",
2629
"title_markdown": "Workspace \"bobby-workspace\" autobuild failed",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceBuildsFailedReport.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": "Report: Workspace Builds Failed For Template",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceCreated.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": "Workspace Created",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

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

Lines changed: 5 additions & 2 deletions
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": "Workspace Deleted",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",
@@ -25,7 +25,10 @@
2525
"reason": "autodeleted due to dormancy"
2626
},
2727
"data": null,
28-
"targets": null
28+
"targets": [
29+
"00000000-0000-0000-0000-000000000000",
30+
"00000000-0000-0000-0000-000000000000"
31+
]
2932
},
3033
"title": "Workspace \"bobby-workspace\" deleted",
3134
"title_markdown": "Workspace \"bobby-workspace\" deleted",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceDeleted_CustomAppearance.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": "Workspace Deleted",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceDormant.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": "Workspace Marked as Dormant",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceManualBuildFailed.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": "Workspace Manual Build Failed",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceManuallyUpdated.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": "Workspace Manually Updated",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceMarkedForDeletion.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": "Workspace Marked for Deletion",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceOutOfDisk.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": "Workspace Out Of Disk",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceOutOfDisk_MultipleVolumes.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": "Workspace Out Of Disk",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateWorkspaceOutOfMemory.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": "Workspace Out Of Memory",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateYourAccountActivated.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": "Your account has been activated",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",

‎coderd/notifications/testdata/rendered-templates/webhook/TemplateYourAccountSuspended.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": "Your account has been suspended",
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