MCPcopy
hub / github.com/apache/answer / CloseQuestion

Method CloseQuestion

internal/service/question_common/question.go:541–571  ·  view source on GitHub ↗
(ctx context.Context, req *schema.CloseQuestionReq)

Source from the content-addressed store, hash-verified

539}
540
541func (qs *QuestionCommon) CloseQuestion(ctx context.Context, req *schema.CloseQuestionReq) error {
542 questionInfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID)
543 if err != nil {
544 return err
545 }
546 if !has {
547 return nil
548 }
549 questionInfo.Status = entity.QuestionStatusClosed
550 err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo.ID, questionInfo.Status)
551 if err != nil {
552 return err
553 }
554
555 closeMeta, _ := json.Marshal(schema.CloseQuestionMeta{
556 CloseType: req.CloseType,
557 CloseMsg: req.CloseMsg,
558 })
559 err = qs.metaCommonService.AddMeta(ctx, req.ID, entity.QuestionCloseReasonKey, string(closeMeta))
560 if err != nil {
561 return err
562 }
563
564 qs.activityQueueService.Send(ctx, &schema.ActivityMsg{
565 UserID: questionInfo.UserID,
566 ObjectID: questionInfo.ID,
567 OriginalObjectID: questionInfo.ID,
568 ActivityTypeKey: constant.ActQuestionClosed,
569 })
570 return nil
571}
572
573// RemoveAnswer delete answer
574func (qs *QuestionCommon) RemoveAnswer(ctx context.Context, id string) (err error) {

Callers 1

Calls 4

GetQuestionMethod · 0.65
UpdateQuestionStatusMethod · 0.65
AddMetaMethod · 0.65
SendMethod · 0.65

Tested by

no test coverage detected