fix(admin): sync moderation review state refresh
This commit is contained in:
parent
e75fd04a28
commit
90649b5b67
4 changed files with 255 additions and 9 deletions
|
|
@ -727,7 +727,9 @@ func (s *Server) handleModerationCases(w http.ResponseWriter, r *http.Request) {
|
|||
writeModerationError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"cases": items})
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"cases": moderationCasesResponse(items),
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleModerationCase(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -744,7 +746,7 @@ func (s *Server) handleModerationCase(w http.ResponseWriter, r *http.Request) {
|
|||
writeError(w, http.StatusNotFound, "moderation case not found")
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, detail)
|
||||
writeJSON(w, http.StatusOK, moderationCaseDetailResponse(detail))
|
||||
}
|
||||
|
||||
func (s *Server) handleModerationReport(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -761,7 +763,7 @@ func (s *Server) handleModerationReport(w http.ResponseWriter, r *http.Request)
|
|||
writeError(w, http.StatusNotFound, "moderation report not found")
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, report)
|
||||
writeJSON(w, http.StatusOK, moderationReportResponse(report))
|
||||
}
|
||||
|
||||
func (s *Server) handleClaimModerationCase(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -800,7 +802,7 @@ func (s *Server) handleDecideModerationCase(w http.ResponseWriter, r *http.Reque
|
|||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"created": created, "case": detail,
|
||||
"created": created, "case": moderationCaseDetailResponse(detail),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -855,10 +857,37 @@ func (s *Server) handleReviewModerationAppeal(w http.ResponseWriter, r *http.Req
|
|||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"created": created, "case": detail,
|
||||
"created": created, "case": moderationCaseDetailResponse(detail),
|
||||
})
|
||||
}
|
||||
|
||||
func moderationCasesResponse(items []domain.ModerationCase) []domain.ModerationCase {
|
||||
if items == nil {
|
||||
return []domain.ModerationCase{}
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func moderationCaseDetailResponse(detail domain.ModerationCaseDetail) domain.ModerationCaseDetail {
|
||||
if detail.Decisions == nil {
|
||||
detail.Decisions = []domain.ModerationDecision{}
|
||||
}
|
||||
if detail.Actions == nil {
|
||||
detail.Actions = []domain.ModerationAction{}
|
||||
}
|
||||
if detail.Appeals == nil {
|
||||
detail.Appeals = []domain.ModerationAppeal{}
|
||||
}
|
||||
return detail
|
||||
}
|
||||
|
||||
func moderationReportResponse(report domain.ModerationReport) domain.ModerationReport {
|
||||
if report.MediaHolds == nil {
|
||||
report.MediaHolds = []domain.ModerationMediaHold{}
|
||||
}
|
||||
return report
|
||||
}
|
||||
|
||||
func moderationDecisionDomain(caseID, appealID int64, request moderationDecisionRequest) domain.ModerationDecisionRequest {
|
||||
actions := make([]domain.ModerationActionDraft, 0, len(request.Actions))
|
||||
for _, action := range request.Actions {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue