From 6a9f5f5e992ee6d008b43aa0b3d172a2bd983a5b Mon Sep 17 00:00:00 2001 From: pluja Date: Sun, 15 Jun 2025 14:38:24 +0000 Subject: [PATCH] Release 202506151438 --- web/src/actions/notifications.ts | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/web/src/actions/notifications.ts b/web/src/actions/notifications.ts index d2c5664..52f3ce5 100644 --- a/web/src/actions/notifications.ts +++ b/web/src/actions/notifications.ts @@ -1,4 +1,3 @@ -import { ActionError } from 'astro:actions' import { z } from 'astro:content' import { defineProtectedAction } from '../lib/defineProtectedAction' @@ -58,28 +57,15 @@ export const notificationActions = { accept: 'json', permissions: 'guest', input: z.object({ - endpoint: z.string().optional(), + endpoint: z.string(), }), handler: async (input, context) => { - if (input.endpoint) { - await prisma.pushSubscription.deleteMany({ - where: { - userId: context.locals.user?.id ?? undefined, - endpoint: input.endpoint, - }, - }) - } else if (context.locals.user) { - await prisma.pushSubscription.deleteMany({ - where: { - userId: context.locals.user.id, - }, - }) - } else { - throw new ActionError({ - code: 'BAD_REQUEST', - message: 'Endpoint is required when user is not logged in.', - }) - } + await prisma.pushSubscription.delete({ + where: { + userId: context.locals.user?.id ?? undefined, + endpoint: input.endpoint, + }, + }) }, }), },