Skip to content

feat(coderd/notifications): improve notification format consistency #14967

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
70f3486
feat(notifications): Improve notification format consistency
SasSwart Oct 3, 2024
7e31a34
chore(coderd/notifications): regenerate notification testdata from th…
SasSwart Oct 5, 2024
cf3afd4
Merge remote-tracking branch 'origin/main' into jjs/consistent-notifi…
SasSwart Oct 5, 2024
4b85f2b
chore(coderd/database): renumber migration
SasSwart Oct 5, 2024
e8ad3ac
chore(coderd/notifications): regenerate testdata
SasSwart Oct 5, 2024
2a4d740
fix(coderd/notifications): remove duplicate function signature
SasSwart Oct 5, 2024
e741c43
chore: remove redundant escaping in migration
SasSwart Oct 5, 2024
adffe60
chore(coderd/notifications): improve failed test feedback
SasSwart Oct 5, 2024
41ed54a
feat(coderd/database): add new information to the account activated n…
SasSwart Oct 7, 2024
5541331
Merge remote-tracking branch 'origin/main' into jjs/additional-notifi…
SasSwart Oct 8, 2024
fe94f0d
chore(coderd/database): rework migration for legibility
SasSwart Oct 8, 2024
98e7501
feat(coderd): send newly required information to notification templates
SasSwart Oct 8, 2024
d8e00c2
feat(coderd/notifications): provide additional context to workspace n…
SasSwart Oct 8, 2024
d6a339f
fix(coderd/notifications): add a missing call to fmt.Sprintf
SasSwart Oct 8, 2024
920ad31
fix(coderd/notifications): fix oversights in template migration
SasSwart Oct 9, 2024
9e938e5
chore(coderd/provisionerdserver): set the displayname in TestNotifica…
SasSwart Oct 9, 2024
59e57ac
chore(coderd): add more robust testing assertions to TestNotifyDelete…
SasSwart Oct 9, 2024
c907238
chore(coderd/notifications): fix migration indentation
SasSwart Oct 9, 2024
2493556
chore(coderd/notifications): regenerate golden files
SasSwart Oct 9, 2024
19dccc8
Merge remote-tracking branch 'origin/main' into jjs/consistent-notifi…
SasSwart Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(coderd/notifications): fix migration indentation
  • Loading branch information
SasSwart committed Oct 9, 2024
commit c907238e38e7223e72660d60dc024608da2a0ed6
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\nUser account **{{.Labels.activated_account_name}}** has been activated.'
WHERE
id = '9f5af851-8408-4e73-a7a1-c6502ba46689';
id = '9f5af851-8408-4e73-a7a1-c6502ba46689';

UPDATE notification_templates
SET
Expand All @@ -24,13 +24,13 @@ WHERE

UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\New user account **{{.Labels.created_account_name}}** has been created.'
body_template = E'Hi {{.UserName}},\n\New user account **{{.Labels.created_account_name}}** has been created.'
WHERE
id = '4e19c0ac-94e1-4532-9515-d1801aa283b2';

UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\nUser account **{{.Labels.deleted_account_name}}** has been deleted.'
body_template = E'Hi {{.UserName}},\n\nUser account **{{.Labels.deleted_account_name}}** has been deleted.'
WHERE
id = 'f44d9314-ad03-4bc8-95d0-5cad491da6b6';

Expand All @@ -43,9 +43,10 @@ WHERE

UPDATE notification_templates
SET body_template = E'Hi {{.UserName}}\n' ||
E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n' ||
E'Reason for update: **{{.Labels.template_version_message}}**'
WHERE id = 'c34a0c09-0704-4cac-bd1c-0c0146811c2b';
E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n' ||
E'Reason for update: **{{.Labels.template_version_message}}**'
WHERE
id = 'c34a0c09-0704-4cac-bd1c-0c0146811c2b';

UPDATE notification_templates
SET
Expand All @@ -55,7 +56,7 @@ WHERE

UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}}\n\nYour workspace **{{.Labels.name}}** was deleted.\nThe specified reason was "**{{.Labels.reason}}{{ if .Labels.initiator }} ({{ .Labels.initiator }}){{end}}**".'
body_template = E'Hi {{.UserName}}\n\nYour workspace **{{.Labels.name}}** was deleted.\nThe specified reason was "**{{.Labels.reason}}{{ if .Labels.initiator }} ({{ .Labels.initiator }}){{end}}**".'
WHERE
id = 'f517da0b-cdc9-410f-ab89-a86107c420ed';

Expand All @@ -78,6 +79,6 @@ WHERE

UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\nA manual build of the workspace **{{.Labels.name}}** using the template **{{.Labels.template_name}}** failed (version: **{{.Labels.template_version_name}}**).\nThe workspace build was initiated by **{{.Labels.initiator}}**.'
body_template = E'Hi {{.UserName}},\n\nA manual build of the workspace **{{.Labels.name}}** using the template **{{.Labels.template_name}}** failed (version: **{{.Labels.template_version_name}}**).\nThe workspace build was initiated by **{{.Labels.initiator}}**.'
WHERE
id = '2faeee0f-26cb-4e96-821c-85ccb9f71513';
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' || -- Add a \n
E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n' ||
E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n' ||
-- Mention the real name of the user who suspended the account:
E'The newly suspended account belongs to **{{.Labels.suspended_account_user_name}}** and was suspended by **{{.Labels.account_suspender_user_name}}**.'
E'The newly suspended account belongs to **{{.Labels.suspended_account_user_name}}** and was suspended by **{{.Labels.account_suspender_user_name}}**.'
WHERE
id = 'b02ddd82-4733-4d02-a2d7-c36f3598997d';

Expand All @@ -15,19 +15,19 @@ UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' || -- Add a \n
-- Mention who suspended the account:
E'Your account **{{.Labels.suspended_account_name}}** has been suspended by **{{.Labels.account_suspender_user_name}}**'
E'Your account **{{.Labels.suspended_account_name}}** has been suspended by **{{.Labels.account_suspender_user_name}}**.'
WHERE
id = '6a2f0609-9b69-4d36-a989-9f5925b6cbff';

-- UserAccountActivated
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' || -- Add a \n
E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n' ||
E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n' ||
-- Mention the real name of the user who activated the account:
E'The newly activated account belongs to **{{.Labels.activated_account_user_name}}** and was activated by **{{.Labels.account_activator_user_name}}**.'
E'The newly activated account belongs to **{{.Labels.activated_account_user_name}}** and was activated by **{{.Labels.account_activator_user_name}}**.'
WHERE
id = '9f5af851-8408-4e73-a7a1-c6502ba46689';
id = '9f5af851-8408-4e73-a7a1-c6502ba46689';

-- YourAccountActivated
UPDATE notification_templates
Expand All @@ -41,17 +41,17 @@ WHERE
-- UserAccountCreated
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' ||
body_template = E'Hi {{.UserName}},\n\n' ||
E'New user account **{{.Labels.created_account_name}}** has been created.\n\n' ||
-- Mention the real name of the user who created the account:
E'This new user account was created for **{{.Labels.created_account_user_name}}** by **{{.Labels.account_creator}}**'
E'This new user account was created for **{{.Labels.created_account_user_name}}** by **{{.Labels.account_creator}}**.'
WHERE
id = '4e19c0ac-94e1-4532-9515-d1801aa283b2';

-- UserAccountDeleted
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' ||
body_template = E'Hi {{.UserName}},\n\n' ||
E'User account **{{.Labels.deleted_account_name}}** has been deleted.\n\n' ||
-- Mention the real name of the user who deleted the account:
E'The deleted account belonged to **{{.Labels.deleted_account_user_name}}** and was deleted by **{{.Labels.account_deleter_user_name}}**.'
Expand All @@ -72,8 +72,8 @@ WHERE
UPDATE notification_templates
SET body_template = E'Hi {{.UserName}},\n\n' || -- Add a comma and a \n
-- Add a \n:
E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n\n' ||
E'Reason for update: **{{.Labels.template_version_message}}**'
E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n\n' ||
E'Reason for update: **{{.Labels.template_version_message}}**.'
WHERE
id = 'c34a0c09-0704-4cac-bd1c-0c0146811c2b';

Expand Down Expand Up @@ -119,7 +119,7 @@ WHERE
-- WorkspaceManualBuildFailed
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}},\n\n' ||
body_template = E'Hi {{.UserName}},\n\n' ||
E'A manual build of the workspace **{{.Labels.name}}** using the template **{{.Labels.template_name}}** failed (version: **{{.Labels.template_version_name}}**).\n\n' ||
-- Mention template display name:
E'The template''s display name was **{{.Labels.template_display_name}}**. ' ||
Expand Down
2 changes: 1 addition & 1 deletion coderd/notifications/notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ func TestNotificationTemplates_Golden(t *testing.T) {
return
}

hint := "run \"DB=ci make update-golden-files\" and commit the changes"
const hint = "run \"DB=ci make update-golden-files\" and commit the changes"

wantBody, err := os.ReadFile(bodyGoldenFile)
require.NoError(t, err, fmt.Sprintf("missing golden notification body file. %s", hint))
Expand Down
Loading