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

Commitdfb6bfa

Browse files
authored
fix(coderd/notifications): exclude unset fields from notifications (#15110)
This PR will ensure that optional fields are ignored when they are unsetin user account related templates.
1 parentf537193 commitdfb6bfa

6 files changed

+90
-12
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- https://github.com/coder/coder/issues/14893
2+
3+
-- UserAccountSuspended
4+
UPDATE notification_templates
5+
SET
6+
body_template= E'Hi {{.UserName}},\n\n'||-- Add a \n
7+
E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n'||
8+
-- Use the conventional initiator label:
9+
E'The newly suspended account belongs to **{{.Labels.suspended_account_user_name}}** and was suspended by **{{.Labels.initiator}}**.'
10+
WHERE
11+
id='b02ddd82-4733-4d02-a2d7-c36f3598997d';
12+
13+
-- UserAccountActivated
14+
UPDATE notification_templates
15+
SET
16+
body_template= E'Hi {{.UserName}},\n\n'||-- Add a \n
17+
E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n'||
18+
-- Use the conventional initiator label:
19+
E'The newly activated account belongs to **{{.Labels.activated_account_user_name}}** and was activated by **{{.Labels.initiator}}**.'
20+
WHERE
21+
id='9f5af851-8408-4e73-a7a1-c6502ba46689';
22+
23+
-- UserAccountCreated
24+
UPDATE notification_templates
25+
SET
26+
body_template= E'Hi {{.UserName}},\n\n'||
27+
E'New user account **{{.Labels.created_account_name}}** has been created.\n\n'||
28+
-- Use the conventional initiator label:
29+
E'This new user account was created for **{{.Labels.created_account_user_name}}** by **{{.Labels.initiator}}**.'
30+
WHERE
31+
id='4e19c0ac-94e1-4532-9515-d1801aa283b2';
32+
33+
-- UserAccountDeleted
34+
UPDATE notification_templates
35+
SET
36+
body_template= E'Hi {{.UserName}},\n\n'||
37+
E'User account **{{.Labels.deleted_account_name}}** has been deleted.\n\n'||
38+
-- Use the conventional initiator label:
39+
E'The deleted account belonged to **{{.Labels.deleted_account_user_name}}** and was deleted by **{{.Labels.initiator}}**.'
40+
WHERE
41+
id='f44d9314-ad03-4bc8-95d0-5cad491da6b6';
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
-- https://github.com/coder/coder/issues/14893
3+
4+
-- UserAccountSuspended
5+
UPDATE notification_templates
6+
SET
7+
body_template= E'Hi {{.UserName}},\n\n'||
8+
E'User account **{{.Labels.suspended_account_name}}** has been suspended.\n\n'||
9+
E'The account {{if .Labels.suspended_account_user_name}}belongs to **{{.Labels.suspended_account_user_name}}** and it {{end}}was suspended by **{{.Labels.initiator}}**.'
10+
11+
WHERE
12+
id='b02ddd82-4733-4d02-a2d7-c36f3598997d';
13+
14+
-- UserAccountActivated
15+
UPDATE notification_templates
16+
SET
17+
body_template= E'Hi {{.UserName}},\n\n'||-- Add a \n
18+
E'User account **{{.Labels.activated_account_name}}** has been activated.\n\n'||
19+
E'The account {{if .Labels.activated_account_user_name}}belongs to **{{.Labels.activated_account_user_name}}** and it {{ end }}was activated by **{{.Labels.initiator}}**.'
20+
WHERE
21+
id='9f5af851-8408-4e73-a7a1-c6502ba46689';
22+
23+
-- UserAccountCreated
24+
UPDATE notification_templates
25+
SET
26+
body_template= E'Hi {{.UserName}},\n\n'||
27+
E'New user account **{{.Labels.created_account_name}}** has been created.\n\n'||
28+
E'This new user account was created {{if .Labels.created_account_user_name}}for **{{.Labels.created_account_user_name}}** {{end}}by **{{.Labels.initiator}}**.'
29+
WHERE
30+
id='4e19c0ac-94e1-4532-9515-d1801aa283b2';
31+
32+
-- UserAccountDeleted
33+
UPDATE notification_templates
34+
SET
35+
body_template= E'Hi {{.UserName}},\n\n'||
36+
E'User account **{{.Labels.deleted_account_name}}** has been deleted.\n\n'||
37+
E'The deleted account {{if .Labels.deleted_account_user_name}}belonged to **{{.Labels.deleted_account_user_name}}** and {{end}}was deleted by **{{.Labels.initiator}}**.'
38+
WHERE
39+
id='f44d9314-ad03-4bc8-95d0-5cad491da6b6';

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Hi Bobby,
1414

1515
User account bobby has been activated.
1616

17-
The newly activated account belongs to William Tables and was activated by =
18-
rob.
17+
The account belongs to William Tables and it was activated by rob.
1918

2019

2120
View accounts: http://test.com/deployment/users?filter=3Dstatus%3Aactive
@@ -52,8 +51,8 @@ argin: 8px 0 32px; line-height: 1.5;">
5251

5352
<p>User account <strong>bobby</strong> has been activated.</p>
5453

55-
<p>Thenewly activatedaccount belongs to <strong>William Tables</strong>a=
56-
nd was activated by <strong>rob</strong>.</p>
54+
<p>The account belongs to <strong>William Tables</strong>and it was activa=
55+
ted by <strong>rob</strong>.</p>
5756
</div>
5857
<div style=3D"text-align: center; margin-top: 32px;">
5958
=20

‎coderd/notifications/testdata/rendered-templates/smtp/TemplateUserAccountSuspended.html.golden

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Hi Bobby,
1414

1515
User account bobby has been suspended.
1616

17-
The newly suspended account belongs to William Tables and was suspended by =
18-
rob.
17+
The account belongs to William Tables and it was suspended by rob.
1918

2019

2120
View suspended accounts: http://test.com/deployment/users?filter=3Dstatus%3=
@@ -53,8 +52,8 @@ argin: 8px 0 32px; line-height: 1.5;">
5352

5453
<p>User account <strong>bobby</strong> has been suspended.</p>
5554

56-
<p>Thenewly suspendedaccount belongs to <strong>William Tables</strong>a=
57-
nd was suspended by <strong>rob</strong>.</p>
55+
<p>The account belongs to <strong>William Tables</strong>and it was suspen=
56+
ded by <strong>rob</strong>.</p>
5857
</div>
5958
<div style=3D"text-align: center; margin-top: 32px;">
6059
=20

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
},
2525
"title": "User account \"bobby\" activated",
2626
"title_markdown": "User account \"bobby\" activated",
27-
"body": "Hi Bobby,\n\nUser account bobby has been activated.\n\nThenewly activatedaccount belongs to William Tables and was activated by rob.",
28-
"body_markdown": "Hi Bobby,\n\nUser account **bobby** has been activated.\n\nThenewly activatedaccount belongs to **William Tables** and was activated by **rob**."
27+
"body": "Hi Bobby,\n\nUser account bobby has been activated.\n\nThe account belongs to William Tables and it was activated by rob.",
28+
"body_markdown": "Hi Bobby,\n\nUser account **bobby** has been activated.\n\nThe account belongs to **William Tables** and it was activated by **rob**."
2929
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
},
2525
"title": "User account \"bobby\" suspended",
2626
"title_markdown": "User account \"bobby\" suspended",
27-
"body": "Hi Bobby,\n\nUser account bobby has been suspended.\n\nThenewly suspendedaccount belongs to William Tables and was suspended by rob.",
28-
"body_markdown": "Hi Bobby,\n\nUser account **bobby** has been suspended.\n\nThenewly suspendedaccount belongs to **William Tables** and was suspended by **rob**."
27+
"body": "Hi Bobby,\n\nUser account bobby has been suspended.\n\nThe account belongs to William Tables and it was suspended by rob.",
28+
"body_markdown": "Hi Bobby,\n\nUser account **bobby** has been suspended.\n\nThe account belongs to **William Tables** and it was suspended by **rob**."
2929
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp