Openstatus www.openstatus.dev

fix: update notification schema (#1617)

authored by

Maximilian Kaske and committed by
GitHub
22b58ab1 330f418b

+11 -5
+1 -4
apps/dashboard/src/components/data-table/notifications/data-table-row-actions.tsx
··· 70 70 await updateNotifierMutation.mutateAsync({ 71 71 id: props.row.original.id, 72 72 name: values.name, 73 - data: 74 - typeof values.data === "string" 75 - ? { [values.provider]: values.data } 76 - : values.data, 73 + data: { [values.provider]: values.data }, 77 74 monitors: values.monitors, 78 75 }); 79 76 }}
+10 -1
packages/api/src/router/notification.ts
··· 275 275 id: z.number(), 276 276 name: z.string(), 277 277 data: z.record( 278 - z.string(), 278 + z.enum(notificationProvider), 279 279 z.string().or(z.record(z.string(), z.string())), 280 280 ), 281 281 monitors: z.array(z.number()), ··· 298 298 throw new TRPCError({ 299 299 code: "FORBIDDEN", 300 300 message: "You don't have access to all the monitors.", 301 + }); 302 + } 303 + 304 + const _data = NotificationDataSchema.safeParse(opts.input.data); 305 + 306 + if (!_data.success) { 307 + throw new TRPCError({ 308 + code: "BAD_REQUEST", 309 + message: SchemaError.fromZod(_data.error, opts.input).message, 301 310 }); 302 311 } 303 312