fix: add external traffic monitoring and webhook alerts
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 6s
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 6s
This commit is contained in:
@@ -18,7 +18,7 @@ const getPayoutMode = (task: {
|
||||
return "PAYMENT_PENDING";
|
||||
};
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(request: Request) {
|
||||
const tasks = await prisma.task.findMany({
|
||||
where: { status: TaskStatus.OPEN },
|
||||
orderBy: { created_at: "desc" },
|
||||
@@ -56,6 +56,30 @@ export async function GET() {
|
||||
task_url: `https://agent.wooo.work/tasks/${task.id}`,
|
||||
}));
|
||||
|
||||
const sourceIp =
|
||||
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ??
|
||||
request.headers.get("x-real-ip") ??
|
||||
"unknown";
|
||||
|
||||
void prisma.auditEvent.create({
|
||||
data: {
|
||||
actorType: "USER",
|
||||
actorId: `open-tasks:${sourceIp}`,
|
||||
action: "EXTERNAL_LIST_OPEN_TASKS",
|
||||
entityType: "TASK",
|
||||
entityId: "open-tasks",
|
||||
beforeState: null,
|
||||
afterState: {
|
||||
total_open: publicPayload.length,
|
||||
},
|
||||
reason: "external-discovery",
|
||||
metadata: {
|
||||
source: "public-open-tasks",
|
||||
user_agent: request.headers.get("user-agent") ?? "unknown",
|
||||
},
|
||||
},
|
||||
}).catch(() => {});
|
||||
|
||||
return NextResponse.json({
|
||||
platform: "VibeWork",
|
||||
version: "v1",
|
||||
|
||||
Reference in New Issue
Block a user