Database: - notification_preferences table (user_id, tenant_id, reminder days, email/digest toggles) - notifications table (type, entity link, read/sent tracking, dedup index) Backend: - NotificationService with background goroutine checking reminders hourly - CheckDeadlineReminders: finds deadlines due in N days per user prefs, creates notifications - Overdue deadline detection and notification - Daily digest at 8am: compiles pending notifications into one email - SendEmail via `m mail send` CLI command - Deduplication: same notification type + entity + day = skip - API: GET/PATCH notifications, unread count, mark read/all-read - API: GET/PUT notification-preferences with upsert Frontend: - NotificationBell in header with unread count badge (polls every 30s) - Dropdown panel with notification list, type-colored dots, time-ago, entity links - Mark individual/all as read - NotificationSettings in Einstellungen page: reminder day toggles, email toggle, digest toggle
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/lib/pq"
|
|
)
|
|
|
|
type Notification struct {
|
|
ID uuid.UUID `db:"id" json:"id"`
|
|
TenantID uuid.UUID `db:"tenant_id" json:"tenant_id"`
|
|
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
|
Type string `db:"type" json:"type"`
|
|
EntityType *string `db:"entity_type" json:"entity_type,omitempty"`
|
|
EntityID *uuid.UUID `db:"entity_id" json:"entity_id,omitempty"`
|
|
Title string `db:"title" json:"title"`
|
|
Body *string `db:"body" json:"body,omitempty"`
|
|
SentAt *time.Time `db:"sent_at" json:"sent_at,omitempty"`
|
|
ReadAt *time.Time `db:"read_at" json:"read_at,omitempty"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
}
|
|
|
|
type NotificationPreferences struct {
|
|
UserID uuid.UUID `db:"user_id" json:"user_id"`
|
|
TenantID uuid.UUID `db:"tenant_id" json:"tenant_id"`
|
|
DeadlineReminderDays pq.Int64Array `db:"deadline_reminder_days" json:"deadline_reminder_days"`
|
|
EmailEnabled bool `db:"email_enabled" json:"email_enabled"`
|
|
DailyDigest bool `db:"daily_digest" json:"daily_digest"`
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
|
}
|