mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 22:54:38 +02:00
Add per-type notification preference controls to the Inbox, allowing users to toggle which notification types they receive. This addresses the core pain point of agent-generated status change noise flooding user inboxes. Backend: - New `notification_preference` table (migration 064) with per-user, per-workspace, per-type enabled/disabled toggle - GET/PUT /api/inbox/preferences endpoints for CRUD - notification_listeners.go checks user preferences before creating inbox items, using preloaded per-type batch queries for efficiency - status_changed notifications default to OFF; all others default ON Frontend: - NotificationPreference type and API client methods - TanStack Query options + optimistic mutation hook - Settings dialog accessible via gear icon in Inbox header - Grouped by category: Status, Comments, Assignments, Mentions, Priority, Due dates, Reactions, Agent events, Quick create - Each category shows icon, label, description, and Switch toggle
24 lines
861 B
SQL
24 lines
861 B
SQL
-- name: ListNotificationPreferences :many
|
|
SELECT * FROM notification_preference
|
|
WHERE workspace_id = $1 AND user_id = $2
|
|
ORDER BY notification_type;
|
|
|
|
-- name: UpsertNotificationPreference :one
|
|
INSERT INTO notification_preference (workspace_id, user_id, notification_type, enabled)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (workspace_id, user_id, notification_type)
|
|
DO UPDATE SET enabled = $4, updated_at = now()
|
|
RETURNING *;
|
|
|
|
-- name: GetDisabledNotificationTypes :many
|
|
SELECT notification_type FROM notification_preference
|
|
WHERE workspace_id = $1 AND user_id = $2 AND enabled = false;
|
|
|
|
-- name: ListNotificationPreferencesByType :many
|
|
SELECT user_id, enabled FROM notification_preference
|
|
WHERE workspace_id = $1 AND notification_type = $2;
|
|
|
|
-- name: DeleteNotificationPreferences :exec
|
|
DELETE FROM notification_preference
|
|
WHERE workspace_id = $1 AND user_id = $2;
|