fix(coderd): show correct deletion time in dormancy notification (#26488)

The dormancy notification's "will be automatically deleted in X"
sentence rendered the dormancy threshold instead of the auto-delete
duration. A 30-day threshold rendered as "4 weeks" even when auto-delete
was 90 days; a 60-day threshold rendered as "1 month" with a 7-day
auto-delete. Render the countdown from the auto-delete setting, and skip
the deletion sentence entirely when auto-delete is disabled so the
notification no longer promises a deletion that will never happen.
This commit is contained in:
Zach
2026-06-18 20:17:37 +00:00
committed by GitHub
parent 992b1ffed1
commit 76fa1d4577
10 changed files with 344 additions and 31 deletions
@@ -0,0 +1,5 @@
-- Revert to the body left by migration 000518
-- (000311's wording with the corrected docs URL).
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** has been marked as [**dormant**](https://coder.com/docs/admin/templates/managing-templates/schedule#dormancy-threshold) due to inactivity exceeding the dormancy threshold.\n\n' ||
E'This workspace will be automatically deleted in {{.Labels.timeTilDormant}} if it remains inactive.\n\n' ||
E'To prevent deletion, activate your workspace using the link below.' WHERE id = '0ea69165-ec14-4314-91f1-69566ac3c5a0';
@@ -0,0 +1,11 @@
-- Update the dormant workspace notification body so that the deletion
-- countdown references a dedicated `timeTilDelete` label, and to only
-- include the deletion time if the templates' `time_til_dormant_autodelete`
-- is enabled.
UPDATE notification_templates SET body_template = E'Your workspace **{{.Labels.name}}** has been marked as [**dormant**](https://coder.com/docs/admin/templates/managing-templates/schedule#dormancy-threshold) due to inactivity exceeding the dormancy threshold.\n\n' ||
E'{{ if .Labels.timeTilDelete -}}\n' ||
E'This workspace will be automatically deleted in {{.Labels.timeTilDelete}} if it remains inactive.\n\n' ||
E'To prevent deletion, activate your workspace using the link below.\n' ||
E'{{- else -}}\n' ||
E'Activate your workspace using the link below to resume working in it.\n' ||
E'{{- end }}' WHERE id = '0ea69165-ec14-4314-91f1-69566ac3c5a0';