Delete & View Notification Providers

This commit is contained in:
headlesdev
2025-05-25 00:56:54 +02:00
parent 6ba144b7bd
commit 1e93f84b24
5 changed files with 118 additions and 6 deletions

View File

@@ -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},