feat(notify): bundled notifications, task watchers, daily summary
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m4s

- Per-user routing (own mail / own Discord webhook) for task alarms
  (sent at once), shares, completed shared tasks and watched tasks;
  settings as JSON on the user (GET /auth/me, PATCH /auth/settings).
- Everything but alarms is queued and sent as one message per user
  after NOTIFY_DIGEST_MINUTES (default 5); mails now multipart with an
  HTML version, Discord as one embed. Three failed attempts drop it.
- Own changes never notify the actor, except on watched tasks when
  asked for; "paused" stops everything including alarms.
- Task watchers: POST/DELETE /tasks/{id}/watch, isWatching on tasks.
- Daily summary at a chosen time: overdue, today, tomorrow, plus the
  count of the next 7 days; nothing due, nothing sent.
- Migration 7; jobs do not run in the demo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-30 09:49:13 +01:00
1 parent 362dd3b4c6
commit a69bcbaf10
22 files changed
+1018 -21

No files matched your search

+63
View File
@@ -135,6 +135,67 @@ type User struct {
NotifyBeforeMinutes int `json:"notifyBeforeMinutes"`
OrganizationID string `json:"organizationId,omitempty"`
CreatedAt string `json:"createdAt"`
// Only filled for the user's own profile (GET /auth/me, PATCH /auth/settings)
NotificationSettings *NotificationSettings `json:"notificationSettings,omitempty"`
}
// NotificationSettings: which events reach a user over which channel, the daily summary and a pause.
type NotificationSettings struct {
Paused bool `json:"paused"`
IncludeOwnWatched bool `json:"includeOwnWatched"`
Events NotificationEvents `json:"events"`
DailySummary DailySummary `json:"dailySummary"`
}
type NotificationEvents struct {
Due ChannelChoice `json:"due"` // task alarms (sent at once)
Shared ChannelChoice `json:"shared"` // something was shared with me
TaskDone ChannelChoice `json:"taskDone"` // a shared task was completed
Watched ChannelChoice `json:"watched"` // a watched task changed
}
type ChannelChoice struct {
Email bool `json:"email"`
Discord bool `json:"discord"`
}
type DailySummary struct {
Enabled bool `json:"enabled"`
Time string `json:"time"` // HH:MM, server time zone
Email bool `json:"email"`
Discord bool `json:"discord"`
}
// DefaultNotificationSettings for users who never saved any; task alarms follow the old alarm channels.
func DefaultNotificationSettings(alarmChannels []string) NotificationSettings {
due := ChannelChoice{}
for _, c := range alarmChannels {
due.Email = due.Email || c == "email"
due.Discord = due.Discord || c == "discord"
}
return NotificationSettings{
Events: NotificationEvents{
Due: due,
Shared: ChannelChoice{Email: true},
Watched: ChannelChoice{Email: true, Discord: true},
},
DailySummary: DailySummary{Time: "07:00", Email: true},
}
}
// Channels returns the choice for an event kind (due, shared, taskDone, watched).
func (n NotificationSettings) Channels(kind string) ChannelChoice {
switch kind {
case "due":
return n.Events.Due
case "shared":
return n.Events.Shared
case "taskDone":
return n.Events.TaskDone
case "watched":
return n.Events.Watched
}
return ChannelChoice{}
}
type UserInvite struct {
@@ -167,6 +228,8 @@ type SubTask struct {
}
type Thought struct {
// IsWatching: the requesting user gets notified about changes (task watchers)
IsWatching bool `json:"isWatching,omitempty"`
ID string `json:"id"`
UserID string `json:"userId"`
Content string `json:"content"`