Skip to content

fix: fix dormancy notifications #14029

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 16 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Apply Dannys suggestion
  • Loading branch information
BrunoQuaresma committed Jul 29, 2024
commit e7557d2ce10c161e29ab252b156b975421ed7643
Original file line number Diff line number Diff line change
@@ -1,11 +0,0 @@
UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}}\n\n' || E'Your workspace **{{.Labels.name}}** has been marked as **dormant**.\n' || E'The specified reason was "**{{.Labels.reason}} (initiated by: {{ .Labels.initiator }})**\n\n' || E'Dormancy refers to a workspace being unused for a defined length of time, and after it exceeds {{.Labels.dormancyHours}} hours of dormancy might be deleted.\n' || E'To activate your workspace again, simply use it as normal.'
WHERE
id = '0ea69165-ec14-4314-91f1-69566ac3c5a0';

UPDATE notification_templates
SET
body_template = E'Hi {{.UserName}}\n\n' || E'Your workspace **{{.Labels.name}}** has been marked for **deletion** after {{.Labels.dormancyHours}} hours of dormancy.\n' || E'The specified reason was "**{{.Labels.reason}}**\n\n' || E'Dormancy refers to a workspace being unused for a defined length of time, and after it exceeds {{.Labels.dormancyHours}} hours of dormancy it will be deleted.\n' || E'To prevent your workspace from being deleted, simply use it as normal.'
WHERE
id = '51ce2fdf-c9ca-4be1-8d70-628674f9bc42';
14 changes: 10 additions & 4 deletions coderd/notifications/notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,20 @@ func TestNotifcationTemplatesBody(t *testing.T) {

_, _, sql := dbtestutil.NewDBWithSQLDB(t)

var bodyTmpl string
var (
titleTmpl string
bodyTmpl string
)
err := sql.
QueryRow("SELECT body_template FROM notification_templates WHERE id = $1 LIMIT 1", tc.id).
Scan(&bodyTmpl)
QueryRow("SELECT title_template, body_template FROM notification_templates WHERE id = $1 LIMIT 1", tc.id).
Scan(&titleTmpl, &bodyTmpl)
require.NoError(t, err, "failed to query body template for template:", tc.id)

_, err = render.GoTemplate(titleTmpl, tc.payload, nil)
require.NoError(t, err, "failed to render notification title template")

_, err = render.GoTemplate(bodyTmpl, tc.payload, nil)
require.NoError(t, err, "failed to render notification template")
require.NoError(t, err, "failed to render notification body template")
})
}
}
Expand Down