7.7 신고→알림→블라인드 자동화 훅 o

This commit is contained in:
koreacomp5
2025-10-09 17:09:43 +09:00
parent 15f30c1bc7
commit 05ce9f65ea
2 changed files with 15 additions and 1 deletions

View File

@@ -24,6 +24,20 @@ export async function POST(req: Request, context: { params: Promise<{ id: string
data: { type: "REPORT", message: `신고 발생: post ${id}`, targetType: "POST", targetId: id },
});
// 자동 블라인드 임계치: 신고 3회 이상시 hidden 처리
const stat = await prisma.postStat.upsert({
where: { postId: id },
update: { reportCount: { increment: 1 } },
create: { postId: id, reportCount: 1 },
});
const threshold = 3;
if ((stat.reportCount + 1) >= threshold) {
await prisma.post.update({ where: { id }, data: { status: "hidden" } });
await prisma.adminNotification.create({
data: { type: "AUTO_HIDE", message: `신고 누적 ${threshold}건으로 블라인드됨: post ${id}`, targetType: "POST", targetId: id },
});
}
return NextResponse.json({ ok: true, reportId: report.id });
}