mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 16:51:15 +10:00
feat(notifications): added notification system w/ interwoven refactoring
This commit is contained in:
28
server/api/v1/notifications/[id]/index.delete.ts
Normal file
28
server/api/v1/notifications/[id]/index.delete.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await h3.context.session.getUserId(h3);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const notificationId = getRouterParam(h3, "id");
|
||||
if (!notificationId)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Missing notification ID",
|
||||
});
|
||||
|
||||
const notification = await prisma.notification.delete({
|
||||
where: {
|
||||
id: notificationId,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!notification)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: "Invalid notification ID",
|
||||
});
|
||||
|
||||
return {};
|
||||
});
|
||||
Reference in New Issue
Block a user