feat: notification preferences system with plugin registry

- Add NotificationType and NotificationPreference models
- Add get_notification_types() to BasePlugin for plugin registration
- Add sync_notification_types() to PluginRegistry
- Update create_notification() to check user preferences (returns Notification|None)
- Add API endpoints: GET /types, GET /preferences, PATCH /preferences/{type_key}
- Add NotificationPreferenceUpdate schema
- Mail plugin registers 10 notification types with metadata
- Add Alembic migration 0017 for new tables + seed data
- Frontend: SettingsNotifications page with toggle switches
- Frontend: Settings tab, route, hooks for notification preferences
- i18n: notification settings keys (de/en)
This commit is contained in:
Agent Zero
2026-07-15 21:00:32 +02:00
parent c4d0ec6f7f
commit b0e987f790
15 changed files with 652 additions and 11 deletions
+36
View File
@@ -459,6 +459,42 @@ export function useDeleteNotification() {
});
}
export interface NotificationTypeItem {
type_key: string;
plugin_name: string;
category: string;
label: string;
description: string | null;
is_enabled_by_default: boolean;
is_enabled: boolean;
}
export function useNotificationTypes() {
return useQuery({
queryKey: ['notification-types'],
queryFn: () => apiGet<{ items: NotificationTypeItem[] }>('/notifications/types'),
});
}
export function useNotificationPreferences() {
return useQuery({
queryKey: ['notification-preferences'],
queryFn: () => apiGet<{ items: { type_key: string; is_enabled: boolean }[] }>('/notifications/preferences'),
});
}
export function useUpdateNotificationPreference() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ typeKey, isEnabled }: { typeKey: string; isEnabled: boolean }) =>
apiPatch(`/notifications/preferences/${typeKey}`, { is_enabled: isEnabled }),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['notification-preferences'] });
queryClient.invalidateQueries({ queryKey: ['notification-types'] });
},
});
}
export function usePlugins() {
return useQuery({
queryKey: ['plugins'],