(ctx context.Context, userID string, questionInfo *entity.Question, newAnswerInfo *entity.Answer, oldAnswerInfo *entity.Answer, )
| 514 | } |
| 515 | |
| 516 | func (as *AnswerService) updateAnswerRank(ctx context.Context, userID string, |
| 517 | questionInfo *entity.Question, newAnswerInfo *entity.Answer, oldAnswerInfo *entity.Answer, |
| 518 | ) { |
| 519 | // if this question is already been answered, should cancel old answer rank |
| 520 | if oldAnswerInfo != nil { |
| 521 | err := as.answerActivityService.CancelAcceptAnswer(ctx, userID, |
| 522 | questionInfo.AcceptedAnswerID, questionInfo.ID, questionInfo.UserID, oldAnswerInfo.UserID) |
| 523 | if err != nil { |
| 524 | log.Error(err) |
| 525 | } |
| 526 | } |
| 527 | if newAnswerInfo != nil { |
| 528 | err := as.answerActivityService.AcceptAnswer(ctx, userID, newAnswerInfo.ID, |
| 529 | questionInfo.ID, questionInfo.UserID, newAnswerInfo.UserID, newAnswerInfo.UserID == questionInfo.UserID) |
| 530 | if err != nil { |
| 531 | log.Error(err) |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | func (as *AnswerService) Get(ctx context.Context, answerID, loginUserID string, isAdminModerator bool) (*schema.AnswerInfo, *schema.QuestionInfoResp, bool, error) { |
| 537 | answerInfo, has, err := as.answerRepo.GetByID(ctx, answerID) |
no test coverage detected