Implement multi-user WhatsApp notifications and settings UI
This commit is contained in:
19
app/api/whatsapp/status/route.ts
Normal file
19
app/api/whatsapp/status/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/auth";
|
||||
|
||||
export async function GET() {
|
||||
const session = await auth();
|
||||
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
const userId = session.user.id;
|
||||
const workerUrl = process.env.WHATSAPP_WORKER_URL;
|
||||
const secret = process.env.WHATSAPP_SECRET;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${workerUrl}/status?userId=${userId}&secret=${secret}`);
|
||||
const data = await res.json();
|
||||
return NextResponse.json(data);
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ status: 'error', error: error.message });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user