refactor: move notification domain to lib/notification/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-05 14:22:02 +02:00
parent 8ff5d6f842
commit 051d2f246e
11 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,31 @@
export type NotificationItem = {
id: string;
type: 'REPLY' | 'MENTION';
documentId: string;
referenceId: string;
annotationId: string | null;
read: boolean;
createdAt: string;
actorName: string;
documentTitle: string | null;
};
export { relativeTime } from '$lib/utils/time';
export function parseNotificationEvent(raw: string): NotificationItem | null {
try {
const parsed = JSON.parse(raw);
if (
typeof parsed.id !== 'string' ||
typeof parsed.documentId !== 'string' ||
typeof parsed.actorName !== 'string' ||
!['REPLY', 'MENTION'].includes(parsed.type)
) {
console.warn('Unexpected SSE payload shape:', parsed);
return null;
}
return parsed as NotificationItem;
} catch {
return null;
}
}