From 7b170dfa756dcdbfc80ebc259c429c43f2ddfd59 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Mon, 19 Jan 2026 17:31:17 +0200 Subject: [PATCH] feat: add new_mention notification type with metadata schema --- .../contracts/types/notification.types.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/surfsense_web/contracts/types/notification.types.ts b/surfsense_web/contracts/types/notification.types.ts index 6a11e81b4..1ae1b693c 100644 --- a/surfsense_web/contracts/types/notification.types.ts +++ b/surfsense_web/contracts/types/notification.types.ts @@ -5,7 +5,7 @@ import { documentTypeEnum } from "./document.types"; /** * Notification type enum - matches backend notification types */ -export const notificationTypeEnum = z.enum(["connector_indexing", "document_processing"]); +export const notificationTypeEnum = z.enum(["connector_indexing", "document_processing", "new_mention"]); /** * Notification status enum - used in metadata @@ -68,6 +68,20 @@ export const documentProcessingMetadata = baseNotificationMetadata.extend({ error_message: z.string().nullable().optional(), }); +/** + * New mention metadata schema + */ +export const newMentionMetadata = z.object({ + mention_id: z.number(), + comment_id: z.number(), + message_id: z.number(), + thread_id: z.number(), + thread_title: z.string(), + author_id: z.string(), + author_name: z.string(), + content_preview: z.string(), +}); + /** * Union of all notification metadata types * Use this when the notification type is unknown @@ -75,6 +89,7 @@ export const documentProcessingMetadata = baseNotificationMetadata.extend({ export const notificationMetadata = z.union([ connectorIndexingMetadata, documentProcessingMetadata, + newMentionMetadata, baseNotificationMetadata, ]); @@ -107,6 +122,11 @@ export const documentProcessingNotification = notification.extend({ metadata: documentProcessingMetadata, }); +export const newMentionNotification = notification.extend({ + type: z.literal("new_mention"), + metadata: newMentionMetadata, +}); + // Inferred types export type NotificationTypeEnum = z.infer; export type NotificationStatusEnum = z.infer; @@ -114,7 +134,9 @@ export type DocumentProcessingStageEnum = z.infer; export type ConnectorIndexingMetadata = z.infer; export type DocumentProcessingMetadata = z.infer; +export type NewMentionMetadata = z.infer; export type NotificationMetadata = z.infer; export type Notification = z.infer; export type ConnectorIndexingNotification = z.infer; export type DocumentProcessingNotification = z.infer; +export type NewMentionNotification = z.infer;