SMPT & NTFY Notification Provider

This commit is contained in:
headlesdev
2025-05-25 14:14:26 +02:00
parent 665fb5faaa
commit 1b4a716c3d
11 changed files with 200 additions and 23 deletions

View File

@@ -14,12 +14,20 @@ export async function POST(request: NextRequest) {
const body = await request.json();
const { name, type, config } = schema.parse(body);
if(type !== "TELEGRAM") {
if(type !== "TELEGRAM" && type !== "NTFY" && type !== "SMTP") {
return NextResponse.json({ error: "Invalid notification type" }, { status: 400 });
}
const parsedConfig = JSON.parse(config);
if(parsedConfig.token === "" || parsedConfig.chat_id === "") {
if(type === "TELEGRAM" && (parsedConfig.token === "" || parsedConfig.chat_id === "")) {
return NextResponse.json({ error: "Invalid config" }, { status: 400 });
}
if(type === "NTFY" && (parsedConfig.url === "" || parsedConfig.token === "")) {
return NextResponse.json({ error: "Invalid config" }, { status: 400 });
}
if(type === "SMTP" && (parsedConfig.host === "" || parsedConfig.port === "" || parsedConfig.username === "" || parsedConfig.password === "" || parsedConfig.from === "" || parsedConfig.to === "")) {
return NextResponse.json({ error: "Invalid config" }, { status: 400 });
}