feat(moderation): make moderation more lenient and add timeout fallback behavior
The moderation system now uses a "pass/review" strategy instead of "pass/review/block", treating hard violations the same as review (only routing to manual review rather than auto-rejecting). Add fallback-approve behavior in the hook system so slow moderation APIs never silently block normal content when they time out or get cancelled - timed-out moderation now approves with "ReviewedBy: system" instead of leaving the zero-value result that would reject content. Update post/comment/vote services and handlers to use the new unified behavior. Simplify moderation prompts to emphasize "宁可放过,不可误伤" (prefer false positives over false negatives).
This commit is contained in:
@@ -106,13 +106,8 @@ func (h *PostHandler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
post, err := h.postService.Create(c.Request.Context(), userID, req.Title, content, segments, req.Images, req.ChannelID, req.ClientRequestID)
|
||||
post, err := h.postService.Create(c.Request.Context(), userID, req.Title, content, segments, req.Images, req.ChannelID, req.ClientRequestID)
|
||||
if err != nil {
|
||||
var moderationErr *service.PostModerationRejectedError
|
||||
if errors.As(err, &moderationErr) {
|
||||
response.BadRequest(c, moderationErr.UserMessage())
|
||||
return
|
||||
}
|
||||
// 幂等命中"进行中"占位:提示客户端稍候,避免重复提交
|
||||
if errors.Is(err, service.ErrDuplicatePostRequest) {
|
||||
response.ErrorWithStatusCode(c, http.StatusTooManyRequests, 429, err.Error())
|
||||
|
||||
@@ -42,11 +42,6 @@ func (h *VoteHandler) CreateVotePost(c *gin.Context) {
|
||||
|
||||
post, err := h.voteService.CreateVotePost(c.Request.Context(), userID, &req)
|
||||
if err != nil {
|
||||
var moderationErr *service.PostModerationRejectedError
|
||||
if errors.As(err, &moderationErr) {
|
||||
response.BadRequest(c, moderationErr.UserMessage())
|
||||
return
|
||||
}
|
||||
// 幂等命中"进行中"占位:提示客户端稍候,避免重复提交
|
||||
if errors.Is(err, service.ErrDuplicatePostRequest) {
|
||||
response.ErrorWithStatusCode(c, http.StatusTooManyRequests, 429, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user