Ẩn bài & Báo cáo vi phạm

post module
Endpoints: POST /:publicId/hide · POST /:publicId/report  ·  Cơ chế: report repository · evaluation queue · auto-hide (0.96)
3
Report Types
post · user · circle
PENDING
Default Status
ghi nhận report, admin duyệt sau
Queue
AI Eval
evaluation-report job
0.96
Auto Hide
confidence >= 0.96

User Perspective


Ẩn bài
User có thể ẩn bài khỏi feed bằng route /:publicId/hide. Đây là toggle trực tiếp cờ isGhost trên bài viết (global).
Báo cáo
User gửi reason + type vào /:publicId/report. Hệ thống tạo report, lưu người report, target type, target id.
Tự động
Với report post/circle, worker AI đánh giá độ tin cậy. Nếu confidence >= 0.96 thì bài sẽ bị isHidden=true và bị loại khỏi list/feed.

Report Flow (Implemented)


POST /posts/:publicId/report Validate body: reason + type(post|user|circle) type được normalize thành enum uppercase type = USER? yes Create report (PENDING) no Create report + enqueue evaluation-report job payload: content, reason, reporterId, reportedUserId, type Worker: confidence >= 0.96 -> update post.isHidden = true

Report POST/CIRCLE sẽ được AI đánh giá bất đồng bộ. USER report chỉ tạo record PENDING, chưa có auto-hide.

API Detail


# API / Tính năng Mô tả nghiệp vụ Trạng thái
01
POST /:publicId/hide
Ẩn bài
Toggle isGhost trên bản ghi post (global). Không cho phép ẩn bài của chính mình. done
02
POST /:publicId/report
Báo cáo vi phạm
Request body gồm reasontype. Hệ thống lưu report bằng reportRepository với status=PENDING. done
03
Type validation
post/user/circle
Zod validate enum lowercase, sau đó normalize sang ReportTargetType uppercase để lưu DB. done
04
AI Evaluation Worker
report evaluation
Worker gọi AI để lấy assistantNote + confidence, ghi lại vào bảng reports. done
05
Auto-hide threshold
moderation automation
Nếu confidence >= 0.96 cho type POST/CIRCLE, cập nhật post.isHidden=true và bump cache version. done
06
Admin moderation
manual review
Report vẫn giữ PENDING để admin quyết định bước xử lý cuối cùng. todo

Implementation Progress


✅ Đã có
DTO report gồm reason + type (zod enum + normalize).
Lưu report DB với reporterId, targetType, targetId, status PENDING.
Queue evaluation-report + worker xử lý AI.
Auto-hide bài khi confidence cao và lọc khỏi feed/list bằng isHidden.
⏳ Mở rộng tiếp
Trang admin xử lý report theo action (resolve/dismiss/hide/delete).
Batch dashboard theo confidence để ưu tiên moderation.
Chuẩn hóa taxonomy reason cho analytics báo cáo.

Design Notes


Target mapping
type=user dùng :publicId như user id. type=post/circle dùng publicId của bài viết làm target id.
Safety rule
Chặn self-report cho cả user target và post target. Duplicate report được phép tạo nhiều bản ghi độc lập.
Visibility
Bài isHidden=true không hiện trong list/feed, nhưng vẫn đọc được qua GET /posts/:publicId để phục vụ moderation và audit.