fix NoNeedReview

This commit is contained in:
aichy126 2022-11-24 18:05:56 +08:00
parent bb5594722f
commit c08a9c852e
2 changed files with 14 additions and 6 deletions

View File

@ -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
}

View File

@ -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,