mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-22 20:51:12 +10:00
feat: delete all notifications
This commit is contained in:
25
server/api/v1/notifications/clear.post.ts
Normal file
25
server/api/v1/notifications/clear.post.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const userId = await aclManager.getUserIdACL(h3, ["notifications:mark"]);
|
||||
if (!userId) throw createError({ statusCode: 403 });
|
||||
|
||||
const acls = await aclManager.fetchAllACLs(h3);
|
||||
if (!acls)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: "Got userId but no ACLs - what?",
|
||||
});
|
||||
|
||||
await prisma.notification.deleteMany({
|
||||
where: {
|
||||
userId,
|
||||
acls: {
|
||||
hasSome: acls,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
});
|
||||
Reference in New Issue
Block a user