mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Delete & View Notification Providers
This commit is contained in:
@@ -14,7 +14,14 @@ export async function POST(request: NextRequest) {
|
||||
const body = await request.json();
|
||||
const { name, type, config } = schema.parse(body);
|
||||
|
||||
if(type !== "TELEGRAM") {
|
||||
return NextResponse.json({ error: "Invalid notification type" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsedConfig = JSON.parse(config);
|
||||
if(parsedConfig.token === "" || parsedConfig.chat_id === "") {
|
||||
return NextResponse.json({ error: "Invalid config" }, { status: 400 });
|
||||
}
|
||||
|
||||
const notification = await prisma.notificationProvider.create({
|
||||
data: { name, type: type as NotificationType, config: parsedConfig},
|
||||
|
||||
@@ -3,7 +3,7 @@ import prisma from "@/app/prisma";
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const schema = z.object({
|
||||
notificationId: z.number(),
|
||||
notificationId: z.string(),
|
||||
});
|
||||
|
||||
export async function DELETE(request: NextRequest) {
|
||||
@@ -12,7 +12,7 @@ export async function DELETE(request: NextRequest) {
|
||||
|
||||
try {
|
||||
const notification = await prisma.notificationProvider.delete({
|
||||
where: { id: notificationId.notificationId },
|
||||
where: { id: parseInt(notificationId.notificationId) },
|
||||
});
|
||||
|
||||
return NextResponse.json(notification);
|
||||
|
||||
Reference in New Issue
Block a user