mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
SMPT & NTFY Notification Provider
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user