Release 202506151438
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { ActionError } from 'astro:actions'
|
|
||||||
import { z } from 'astro:content'
|
import { z } from 'astro:content'
|
||||||
|
|
||||||
import { defineProtectedAction } from '../lib/defineProtectedAction'
|
import { defineProtectedAction } from '../lib/defineProtectedAction'
|
||||||
@@ -58,28 +57,15 @@ export const notificationActions = {
|
|||||||
accept: 'json',
|
accept: 'json',
|
||||||
permissions: 'guest',
|
permissions: 'guest',
|
||||||
input: z.object({
|
input: z.object({
|
||||||
endpoint: z.string().optional(),
|
endpoint: z.string(),
|
||||||
}),
|
}),
|
||||||
handler: async (input, context) => {
|
handler: async (input, context) => {
|
||||||
if (input.endpoint) {
|
await prisma.pushSubscription.delete({
|
||||||
await prisma.pushSubscription.deleteMany({
|
where: {
|
||||||
where: {
|
userId: context.locals.user?.id ?? undefined,
|
||||||
userId: context.locals.user?.id ?? undefined,
|
endpoint: input.endpoint,
|
||||||
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.',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user