Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix NoNeedReview

aichy126c08a9c852e09
diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go
index 0efb0ea9..d3a1ca84 100644
--- a/internal/service/answer_service.go
+++ b/internal/service/answer_service.go
@@ -190,6 +190,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
}
func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq) (string, error) {
+ //req.NoNeedReview //true 不需要审核
var canUpdate bool
_, existUnreviewed, err := as.revisionService.ExistUnreviewedByObjectID(ctx, req.ID)
if err != nil {
@@ -232,10 +233,13 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
Log: req.EditSummary,
}
- if answerInfo.UserID != req.UserID && !req.IsAdmin {
+ if req.NoNeedReview || req.IsAdmin || answerInfo.UserID == req.UserID {
+ canUpdate = true
+ }
+
+ if !canUpdate {
revisionDTO.Status = entity.RevisionUnreviewedStatus
} else {
- canUpdate = true
if err = as.answerRepo.UpdateAnswer(ctx, insertData, []string{"original_text", "parsed_text", "update_time"}); err != nil {
return "", err
}
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index 526945ba..815af781 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -264,7 +264,7 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Remov
// UpdateQuestion update question
func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.QuestionUpdate) (questionInfo any, err error) {
- var canUpdateQuestion bool
+ var canUpdate bool
questionInfo = &schema.QuestionInfo{}
_, existUnreviewed, err := qs.revisionService.ExistUnreviewedByObjectID(ctx, req.ID)
@@ -345,11 +345,15 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
Title: question.Title,
Log: req.EditSummary,
}
+
+ if req.NoNeedReview || req.IsAdmin || dbinfo.UserID == req.UserID {
+ canUpdate = true
+ }
+
// It's not you or the administrator that needs to be reviewed
- if dbinfo.UserID != req.UserID && !req.IsAdmin {
+ if !canUpdate {
revisionDTO.Status = entity.RevisionUnreviewedStatus
} else {
- canUpdateQuestion = true
//Direct modification
revisionDTO.Status = entity.RevisionReviewPassStatus
//update question to db
@@ -377,7 +381,7 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
if err != nil {
return
}
- if canUpdateQuestion {
+ if canUpdate {
activity_queue.AddActivity(&schema.ActivityMsg{
UserID: req.UserID,
ObjectID: question.ID,