From 22b58ab1b415cc6119a35d1eb8e9decf19306a97 Mon Sep 17 00:00:00 2001 From: Maximilian Kaske <56969857+mxkaske@users.noreply.github.com> Date: Fri, 5 Dec 2025 11:51:10 +0100 Subject: [PATCH] fix: update notification schema (#1617) --- .../notifications/data-table-row-actions.tsx | 5 +---- packages/api/src/router/notification.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/dashboard/src/components/data-table/notifications/data-table-row-actions.tsx b/apps/dashboard/src/components/data-table/notifications/data-table-row-actions.tsx index 9f091cb17..2d61a4c73 100644 --- a/apps/dashboard/src/components/data-table/notifications/data-table-row-actions.tsx +++ b/apps/dashboard/src/components/data-table/notifications/data-table-row-actions.tsx @@ -70,10 +70,7 @@ export function DataTableRowActions(props: DataTableRowActionsProps) { await updateNotifierMutation.mutateAsync({ id: props.row.original.id, name: values.name, - data: - typeof values.data === "string" - ? { [values.provider]: values.data } - : values.data, + data: { [values.provider]: values.data }, monitors: values.monitors, }); }} diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.ts index 9c09b57e7..bdc2d55d1 100644 --- a/packages/api/src/router/notification.ts +++ b/packages/api/src/router/notification.ts @@ -275,7 +275,7 @@ export const notificationRouter = createTRPCRouter({ id: z.number(), name: z.string(), data: z.record( - z.string(), + z.enum(notificationProvider), z.string().or(z.record(z.string(), z.string())), ), monitors: z.array(z.number()), @@ -301,6 +301,15 @@ export const notificationRouter = createTRPCRouter({ }); } + const _data = NotificationDataSchema.safeParse(opts.input.data); + + if (!_data.success) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: SchemaError.fromZod(_data.error, opts.input).message, + }); + } + db.transaction(async (tx) => { await tx .update(notification) -- 2.54.0