mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: chat auto-archive owner digest notifications (#24643)
Depends on #24642 Adds per-owner digest notifications onto the chat auto-archive subsystem. Each tick's archived rows are grouped by owner, the top 25 titles per owner are rendered into a new `Chats Auto-Archived` notification template, and any remainder surfaces as `and N more`. Each digest is per-tick, so users with large amounts of purgeable data may get multiple notifications in sequence (one per user per tick). The template body branches on `retention_days`: when retention is disabled (`retention_days=0`), users are told archived chats are kept indefinitely rather than falsely claiming imminent deletion. ### Changes - migration `000XXX_chat_auto_archive_notification_template` adds new notification template - `dbpurge`: threads `notifications.Enqueuer` through `New`; and enqueues notification message. - `cli/server.go`: passes `options.NotificationsEnqueuer` into `dbpurge.New`. - `coderd/notifications/events.go`: new `TemplateChatAutoArchiveDigest` UUID. - `coderd/inboxnotifications.go`: inbox registration. - Docs: adds a `Notifications` section to `chat-auto-archive.md`. > 🤖
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DELETE FROM notification_templates WHERE id = '764031be-4863-4220-867b-6ce1a1b7a5f5';
|
||||
@@ -0,0 +1,34 @@
|
||||
-- Template for the per-owner chat auto-archive notification. Enqueue is
|
||||
-- per-tick (see dbpurge.dispatchChatAutoArchive): owners whose backlog
|
||||
-- spans multiple ticks receive multiple notifications, and
|
||||
-- notification_messages dedupe does not collapse them because each
|
||||
-- tick's payload differs. Users who find this noisy can disable the
|
||||
-- template from their notification preferences. The SMTP/webhook
|
||||
-- wrappers prepend "Hi {{.UserName}},", so body_template must not.
|
||||
INSERT INTO notification_templates (
|
||||
id,
|
||||
name,
|
||||
title_template,
|
||||
body_template,
|
||||
actions,
|
||||
"group",
|
||||
method,
|
||||
kind,
|
||||
enabled_by_default
|
||||
)
|
||||
VALUES (
|
||||
'764031be-4863-4220-867b-6ce1a1b7a5f5',
|
||||
'Chats Auto-Archived',
|
||||
E'Chats auto-archived after {{.Data.auto_archive_days}} days of inactivity',
|
||||
E'The following chats were automatically archived:\n\n{{range .Data.archived_chats}}* "{{.title}}" (last active {{.last_activity_humanized}})\n{{end}}{{with .Data.additional_archived_count}}\n...and {{.}} more.\n\n{{end}}\n{{if eq .Data.retention_days "0"}}You can restore any of them from the Agents page; archived chats are kept indefinitely.{{else}}You can restore any of them from the Agents page within {{.Data.retention_days}} days, after which they will be permanently deleted.{{end}}',
|
||||
'[
|
||||
{
|
||||
"label": "View chats",
|
||||
"url": "{{base_url}}/agents?archived=archived"
|
||||
}
|
||||
]'::jsonb,
|
||||
'Chat Events',
|
||||
NULL,
|
||||
'system'::notification_template_kind,
|
||||
true
|
||||
);
|
||||
Reference in New Issue
Block a user