Skip to content

Commit fe24a7a

Browse files
authored
feat(coderd): remove greetings from notifications templates (coder#16991)
This PR aimes to [fix this issue](coder/internal#448) - The main idea is to remove greetings from templates stored in the DB - and instead push it into the template for require methods - for now SMTP.
1 parent bbe7dac commit fe24a7a

File tree

50 files changed

+220
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+220
-123
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
2+
E'Your workspace **{{.Labels.name}}** was deleted.\n\n' ||
3+
E'The specified reason was "**{{.Labels.reason}}{{ if .Labels.initiator }} ({{ .Labels.initiator }}){{end}}**".' WHERE id = 'f517da0b-cdc9-410f-ab89-a86107c420ed';
4+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
5+
E'Automatic build of your workspace **{{.Labels.name}}** failed.\n\n' ||
6+
E'The specified reason was "**{{.Labels.reason}}**".' WHERE id = '381df2a9-c0c0-4749-420f-80a9280c66f9';
7+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
8+
E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n\n' ||
9+
E'Reason for update: **{{.Labels.template_version_message}}**.' WHERE id = 'c34a0c09-0704-4cac-bd1c-0c0146811c2b';
10+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
11+
E'New user account **{{.Labels.created_account_name}}** has been created.\n\n' ||
12+
E'This new user account was created {{if .Labels.created_account_user_name}}for **{{.Labels.created_account_user_name}}** {{end}}by **{{.Labels.initiator}}**.' WHERE id = '4e19c0ac-94e1-4532-9515-d1801aa283b2';
13+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
14+
E'User account **{{.Labels.deleted_account_name}}** has been deleted.\n\n' ||
15+
E'The deleted account {{if .Labels.deleted_account_user_name}}belonged to **{{.Labels.deleted_account_user_name}}** and {{end}}was deleted by **{{.Labels.initiator}}**.' WHERE id = 'f44d9314-ad03-4bc8-95d0-5cad491da6b6';
16+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
17+
E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n' ||
18+
E'The account {{if .Labels.suspended_account_user_name}}belongs to **{{.Labels.suspended_account_user_name}}** and it {{end}}was suspended by **{{.Labels.initiator}}**.' WHERE id = 'b02ddd82-4733-4d02-a2d7-c36f3598997d';
19+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
20+
E'Your account **{{.Labels.suspended_account_name}}** has been suspended by **{{.Labels.initiator}}**.' WHERE id = '6a2f0609-9b69-4d36-a989-9f5925b6cbff';
21+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
22+
E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n' ||
23+
E'The account {{if .Labels.activated_account_user_name}}belongs to **{{.Labels.activated_account_user_name}}** and it {{ end }}was activated by **{{.Labels.initiator}}**.' WHERE id = '9f5af851-8408-4e73-a7a1-c6502ba46689';
24+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
25+
E'Your account **{{.Labels.activated_account_name}}** has been activated by **{{.Labels.initiator}}**.' WHERE id = '1a6a6bea-ee0a-43e2-9e7c-eabdb53730e4';
26+
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}}**.' WHERE id = '2faeee0f-26cb-4e96-821c-85ccb9f71513';
27+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},
28+
29+
Template **{{.Labels.template_display_name}}** has failed to build {{.Data.failed_builds}}/{{.Data.total_builds}} times over the last {{.Data.report_frequency}}.
30+
31+
**Report:**
32+
{{range $version := .Data.template_versions}}
33+
**{{$version.template_version_name}}** failed {{$version.failed_count}} time{{if gt $version.failed_count 1.0}}s{{end}}:
34+
{{range $build := $version.failed_builds}}
35+
* [{{$build.workspace_owner_username}} / {{$build.workspace_name}} / #{{$build.build_number}}]({{base_url}}/@{{$build.workspace_owner_username}}/{{$build.workspace_name}}/builds/{{$build.build_number}})
36+
{{- end}}
37+
{{end}}
38+
We recommend reviewing these issues to ensure future builds are successful.' WHERE id = '34a20db2-e9cc-4a93-b0e4-8569699d7a00';
39+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\nUse the link below to reset your password.\n\nIf you did not make this request, you can ignore this message.' WHERE id = '62f86a30-2330-4b61-a26d-311ff3b608cf';
40+
UPDATE notification_templates SET body_template = E'Hello {{.UserName}},\n\n'||
41+
E'The template **{{.Labels.template}}** has been deprecated with the following message:\n\n' ||
42+
E'**{{.Labels.message}}**\n\n' ||
43+
E'New workspaces may not be created from this template. Existing workspaces will continue to function normally.' WHERE id = 'f40fae84-55a2-42cd-99fa-b41c1ca64894';
44+
UPDATE notification_templates SET body_template = E'Hello {{.UserName}},\n\n'||
45+
E'The workspace **{{.Labels.workspace}}** has been created from the template **{{.Labels.template}}** using version **{{.Labels.version}}**.' WHERE id = '281fdf73-c6d6-4cbb-8ff5-888baf8a2fff';
46+
UPDATE notification_templates SET body_template = E'Hello {{.UserName}},\n\n'||
47+
E'A new workspace build has been manually created for your workspace **{{.Labels.workspace}}** by **{{.Labels.initiator}}** to update it to version **{{.Labels.version}}** of template **{{.Labels.template}}**.' WHERE id = 'd089fe7b-d5c5-4c0c-aaf5-689859f7d392';
48+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n'||
49+
E'Your workspace **{{.Labels.workspace}}** has reached the memory usage threshold set at **{{.Labels.threshold}}**.' WHERE id = 'a9d027b4-ac49-4fb1-9f6d-45af15f64e7a';
50+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n'||
51+
E'{{ if eq (len .Data.volumes) 1 }}{{ $volume := index .Data.volumes 0 }}'||
52+
E'Volume **`{{$volume.path}}`** is over {{$volume.threshold}} full in workspace **{{.Labels.workspace}}**.'||
53+
E'{{ else }}'||
54+
E'The following volumes are nearly full in workspace **{{.Labels.workspace}}**\n\n'||
55+
E'{{ range $volume := .Data.volumes }}'||
56+
E'- **`{{$volume.path}}`** is over {{$volume.threshold}} full\n'||
57+
E'{{ end }}'||
58+
E'{{ end }}' WHERE id = 'f047f6a3-5713-40f7-85aa-0394cce9fa3a';
59+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n'||
60+
E'This is a test notification.' WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';
61+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n' ||
62+
E'The template **{{.Labels.name}}** was deleted by **{{ .Labels.initiator }}**.\n\n' WHERE id = '29a09665-2a4c-403f-9648-54301670e7be';
63+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n'||
64+
E'Your workspace **{{.Labels.name}}** has been marked as [**dormant**](https://coder.com/docs/templates/schedule#dormancy-threshold-enterprise) because of {{.Labels.reason}}.\n' ||
65+
E'Dormant workspaces are [automatically deleted](https://coder.com/docs/templates/schedule#dormancy-auto-deletion-enterprise) after {{.Labels.timeTilDormant}} of inactivity.\n' ||
66+
E'To prevent deletion, use your workspace with the link below.' WHERE id = '0ea69165-ec14-4314-91f1-69566ac3c5a0';
67+
UPDATE notification_templates SET body_template = E'Hi {{.UserName}},\n\n'||
68+
E'Your workspace **{{.Labels.name}}** has been marked for **deletion** after {{.Labels.timeTilDormant}} of [dormancy](https://coder.com/docs/templates/schedule#dormancy-auto-deletion-enterprise) because of {{.Labels.reason}}.\n' ||
69+
E'To prevent deletion, use your workspace with the link below.' WHERE id = '51ce2fdf-c9ca-4be1-8d70-628674f9bc42';
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** was deleted.\n\n' ||
2+
E'The specified reason was "**{{.Labels.reason}}{{ if .Labels.initiator }} ({{ .Labels.initiator }}){{end}}**".' WHERE id = 'f517da0b-cdc9-410f-ab89-a86107c420ed';
3+
UPDATE notification_templates SET body_template = E'Automatic build of your workspace **{{.Labels.name}}** failed.\n\n' ||
4+
E'The specified reason was "**{{.Labels.reason}}**".' WHERE id = '381df2a9-c0c0-4749-420f-80a9280c66f9';
5+
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** has been updated automatically to the latest template version ({{.Labels.template_version_name}}).\n\n' ||
6+
E'Reason for update: **{{.Labels.template_version_message}}**.' WHERE id = 'c34a0c09-0704-4cac-bd1c-0c0146811c2b';
7+
UPDATE notification_templates SET body_template = E'New user account **{{.Labels.created_account_name}}** has been created.\n\n' ||
8+
E'This new user account was created {{if .Labels.created_account_user_name}}for **{{.Labels.created_account_user_name}}** {{end}}by **{{.Labels.initiator}}**.' WHERE id = '4e19c0ac-94e1-4532-9515-d1801aa283b2';
9+
UPDATE notification_templates SET body_template = E'User account **{{.Labels.deleted_account_name}}** has been deleted.\n\n' ||
10+
E'The deleted account {{if .Labels.deleted_account_user_name}}belonged to **{{.Labels.deleted_account_user_name}}** and {{end}}was deleted by **{{.Labels.initiator}}**.' WHERE id = 'f44d9314-ad03-4bc8-95d0-5cad491da6b6';
11+
UPDATE notification_templates SET body_template = E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n' ||
12+
E'The account {{if .Labels.suspended_account_user_name}}belongs to **{{.Labels.suspended_account_user_name}}** and it {{end}}was suspended by **{{.Labels.initiator}}**.' WHERE id = 'b02ddd82-4733-4d02-a2d7-c36f3598997d';
13+
UPDATE notification_templates SET body_template = E'Your account **{{.Labels.suspended_account_name}}** has been suspended by **{{.Labels.initiator}}**.' WHERE id = '6a2f0609-9b69-4d36-a989-9f5925b6cbff';
14+
UPDATE notification_templates SET body_template = E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n' ||
15+
E'The account {{if .Labels.activated_account_user_name}}belongs to **{{.Labels.activated_account_user_name}}** and it {{ end }}was activated by **{{.Labels.initiator}}**.' WHERE id = '9f5af851-8408-4e73-a7a1-c6502ba46689';
16+
UPDATE notification_templates SET body_template = E'Your account **{{.Labels.activated_account_name}}** has been activated by **{{.Labels.initiator}}**.' WHERE id = '1a6a6bea-ee0a-43e2-9e7c-eabdb53730e4';
17+
UPDATE notification_templates SET body_template = E'A 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';
18+
UPDATE notification_templates SET body_template = E'Template **{{.Labels.template_display_name}}** has failed to build {{.Data.failed_builds}}/{{.Data.total_builds}} times over the last {{.Data.report_frequency}}.
19+
20+
**Report:**
21+
{{range $version := .Data.template_versions}}
22+
**{{$version.template_version_name}}** failed {{$version.failed_count}} time{{if gt $version.failed_count 1.0}}s{{end}}:
23+
{{range $build := $version.failed_builds}}
24+
* [{{$build.workspace_owner_username}} / {{$build.workspace_name}} / #{{$build.build_number}}]({{base_url}}/@{{$build.workspace_owner_username}}/{{$build.workspace_name}}/builds/{{$build.build_number}})
25+
{{- end}}
26+
{{end}}
27+
We recommend reviewing these issues to ensure future builds are successful.' WHERE id = '34a20db2-e9cc-4a93-b0e4-8569699d7a00';
28+
UPDATE notification_templates SET body_template = E'Use the link below to reset your password.\n\nIf you did not make this request, you can ignore this message.' WHERE id = '62f86a30-2330-4b61-a26d-311ff3b608cf';
29+
UPDATE notification_templates SET body_template = E'The template **{{.Labels.template}}** has been deprecated with the following message:\n\n' ||
30+
E'**{{.Labels.message}}**\n\n' ||
31+
E'New workspaces may not be created from this template. Existing workspaces will continue to function normally.' WHERE id = 'f40fae84-55a2-42cd-99fa-b41c1ca64894';
32+
UPDATE notification_templates SET body_template = E'The workspace **{{.Labels.workspace}}** has been created from the template **{{.Labels.template}}** using version **{{.Labels.version}}**.' WHERE id = '281fdf73-c6d6-4cbb-8ff5-888baf8a2fff';
33+
UPDATE notification_templates SET body_template = E'A new workspace build has been manually created for your workspace **{{.Labels.workspace}}** by **{{.Labels.initiator}}** to update it to version **{{.Labels.version}}** of template **{{.Labels.template}}**.' WHERE id = 'd089fe7b-d5c5-4c0c-aaf5-689859f7d392';
34+
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.workspace}}** has reached the memory usage threshold set at **{{.Labels.threshold}}**.' WHERE id = 'a9d027b4-ac49-4fb1-9f6d-45af15f64e7a';
35+
UPDATE notification_templates SET body_template = E'{{ if eq (len .Data.volumes) 1 }}{{ $volume := index .Data.volumes 0 }}'||
36+
E'Volume **`{{$volume.path}}`** is over {{$volume.threshold}} full in workspace **{{.Labels.workspace}}**.'||
37+
E'{{ else }}'||
38+
E'The following volumes are nearly full in workspace **{{.Labels.workspace}}**\n\n'||
39+
E'{{ range $volume := .Data.volumes }}'||
40+
E'- **`{{$volume.path}}`** is over {{$volume.threshold}} full\n'||
41+
E'{{ end }}'||
42+
E'{{ end }}' WHERE id = 'f047f6a3-5713-40f7-85aa-0394cce9fa3a';
43+
UPDATE notification_templates SET body_template = E'This is a test notification.' WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';
44+
UPDATE notification_templates SET body_template = E'The template **{{.Labels.name}}** was deleted by **{{ .Labels.initiator }}**.\n\n' WHERE id = '29a09665-2a4c-403f-9648-54301670e7be';
45+
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** has been marked as [**dormant**](https://coder.com/docs/templates/schedule#dormancy-threshold-enterprise) because of {{.Labels.reason}}.\n' ||
46+
E'Dormant workspaces are [automatically deleted](https://coder.com/docs/templates/schedule#dormancy-auto-deletion-enterprise) after {{.Labels.timeTilDormant}} of inactivity.\n' ||
47+
E'To prevent deletion, use your workspace with the link below.' WHERE id = '0ea69165-ec14-4314-91f1-69566ac3c5a0';
48+
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** has been marked for **deletion** after {{.Labels.timeTilDormant}} of [dormancy](https://coder.com/docs/templates/schedule#dormancy-auto-deletion-enterprise) because of {{.Labels.reason}}.\n' ||
49+
E'To prevent deletion, use your workspace with the link below.' WHERE id = '51ce2fdf-c9ca-4be1-8d70-628674f9bc42';

coderd/notifications/dispatch/smtp/html.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{{ .Labels._subject }}
1515
</h1>
1616
<div style="line-height: 1.5;">
17+
<p>Hi {{ .UserName }},</p>
1718
{{ .Labels._body }}
1819
</div>
1920
<div style="text-align: center; margin-top: 32px;">

coderd/notifications/dispatch/smtp/plaintext.gotmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Hi {{ .UserName }},
2+
13
{{ .Labels._body }}
24

35
{{ range $action := .Actions }}

coderd/notifications/testdata/rendered-templates/smtp/TemplateTemplateDeleted.html.golden

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ argin: 8px 0 32px; line-height: 1.5;">
4646
</h1>
4747
<div style=3D"line-height: 1.5;">
4848
<p>Hi Bobby,</p>
49-
50-
<p>The template <strong>Bobby&rsquo;s Template</strong> was deleted by <str=
51-
ong>rob</strong>.</p>
49+
<p>The template <strong>Bobby&rsquo;s Template</strong> was deleted=
50+
by <strong>rob</strong>.</p>
5251
</div>
5352
<div style=3D"text-align: center; margin-top: 32px;">
5453
=20

coderd/notifications/testdata/rendered-templates/smtp/TemplateTemplateDeprecated.html.golden

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MIME-Version: 1.0
1010
Content-Transfer-Encoding: quoted-printable
1111
Content-Type: text/plain; charset=UTF-8
1212

13-
Hello Bobby,
13+
Hi Bobby,
1414

1515
The template alpha has been deprecated with the following message:
1616

@@ -53,10 +53,9 @@ argin: 8px 0 32px; line-height: 1.5;">
5353
Template 'alpha' has been deprecated
5454
</h1>
5555
<div style=3D"line-height: 1.5;">
56-
<p>Hello Bobby,</p>
57-
58-
<p>The template <strong>alpha</strong> has been deprecated with the followi=
59-
ng message:</p>
56+
<p>Hi Bobby,</p>
57+
<p>The template <strong>alpha</strong> has been deprecated with the=
58+
following message:</p>
6059

6160
<p><strong>This template has been replaced by beta</strong></p>
6261

coderd/notifications/testdata/rendered-templates/smtp/TemplateTestNotification.html.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ argin: 8px 0 32px; line-height: 1.5;">
4747
</h1>
4848
<div style=3D"line-height: 1.5;">
4949
<p>Hi Bobby,</p>
50-
51-
<p>This is a test notification.</p>
50+
<p>This is a test notification.</p>
5251
</div>
5352
<div style=3D"text-align: center; margin-top: 32px;">
5453
=20

coderd/notifications/testdata/rendered-templates/smtp/TemplateUserAccountActivated.html.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ argin: 8px 0 32px; line-height: 1.5;">
4848
</h1>
4949
<div style=3D"line-height: 1.5;">
5050
<p>Hi Bobby,</p>
51-
52-
<p>User account <strong>bobby</strong> has been activated.</p>
51+
<p>User account <strong>bobby</strong> has been activated.</p>
5352

5453
<p>The account belongs to <strong>William Tables</strong> and it was activa=
5554
ted by <strong>rob</strong>.</p>

coderd/notifications/testdata/rendered-templates/smtp/TemplateUserAccountCreated.html.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ argin: 8px 0 32px; line-height: 1.5;">
4848
</h1>
4949
<div style=3D"line-height: 1.5;">
5050
<p>Hi Bobby,</p>
51-
52-
<p>New user account <strong>bobby</strong> has been created.</p>
51+
<p>New user account <strong>bobby</strong> has been created.</p>
5352

5453
<p>This new user account was created for <strong>William Tables</strong> by=
5554
<strong>rob</strong>.</p>

coderd/notifications/testdata/rendered-templates/smtp/TemplateUserAccountDeleted.html.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ argin: 8px 0 32px; line-height: 1.5;">
4848
</h1>
4949
<div style=3D"line-height: 1.5;">
5050
<p>Hi Bobby,</p>
51-
52-
<p>User account <strong>bobby</strong> has been deleted.</p>
51+
<p>User account <strong>bobby</strong> has been deleted.</p>
5352

5453
<p>The deleted account belonged to <strong>William Tables</strong> and was =
5554
deleted by <strong>rob</strong>.</p>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy