You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/03/15 08:22:21 UTC

(incubator-answer) branch feat/1.3.0/review updated: fix(review): change revision to short id if needed

This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch feat/1.3.0/review
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/feat/1.3.0/review by this push:
     new 758f79b7 fix(review): change revision to short id if needed
758f79b7 is described below

commit 758f79b7dde82a8ff07118f983e55ccd8a37cd76
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Fri Mar 15 16:22:08 2024 +0800

    fix(review): change revision to short id if needed
---
 internal/service/content/revision_service.go | 12 ++++++++++++
 internal/service/object_info/object_info.go  |  8 --------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/internal/service/content/revision_service.go b/internal/service/content/revision_service.go
index f39e055a..efea1ce1 100644
--- a/internal/service/content/revision_service.go
+++ b/internal/service/content/revision_service.go
@@ -44,6 +44,7 @@ import (
 	usercommon "github.com/apache/incubator-answer/internal/service/user_common"
 	"github.com/apache/incubator-answer/pkg/converter"
 	"github.com/apache/incubator-answer/pkg/obj"
+	"github.com/apache/incubator-answer/pkg/uid"
 	"github.com/jinzhu/copier"
 	"github.com/segmentfault/pacman/errors"
 	"github.com/segmentfault/pacman/log"
@@ -397,6 +398,10 @@ func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisi
 		tagInfo      *schema.GetTagResp
 	)
 
+	shortID := handler.GetEnableShortID(ctx)
+	if shortID {
+		item.ObjectID = uid.EnShortID(item.ObjectID)
+	}
 	switch item.ObjectType {
 	case constant.ObjectTypeStrMapping["question"]:
 		err = json.Unmarshal([]byte(item.Content), &question)
@@ -404,6 +409,9 @@ func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisi
 			break
 		}
 		questionInfo = rs.questionCommon.ShowFormatWithTag(ctx, &question)
+		if shortID {
+			questionInfo.ID = uid.EnShortID(questionInfo.ID)
+		}
 		item.ContentParsed = questionInfo
 	case constant.ObjectTypeStrMapping["answer"]:
 		err = json.Unmarshal([]byte(item.Content), &answer)
@@ -411,6 +419,10 @@ func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisi
 			break
 		}
 		answerInfo = rs.answerService.ShowFormat(ctx, &answer)
+		if shortID {
+			answerInfo.ID = uid.EnShortID(answerInfo.ID)
+			answerInfo.QuestionID = uid.EnShortID(answerInfo.QuestionID)
+		}
 		item.ContentParsed = answerInfo
 	case constant.ObjectTypeStrMapping["tag"]:
 		err = json.Unmarshal([]byte(item.Content), &tag)
diff --git a/internal/service/object_info/object_info.go b/internal/service/object_info/object_info.go
index 4f000900..0e1dbdc2 100644
--- a/internal/service/object_info/object_info.go
+++ b/internal/service/object_info/object_info.go
@@ -23,7 +23,6 @@ import (
 	"context"
 
 	"github.com/apache/incubator-answer/internal/base/constant"
-	"github.com/apache/incubator-answer/internal/base/handler"
 	"github.com/apache/incubator-answer/internal/base/reason"
 	"github.com/apache/incubator-answer/internal/schema"
 	answercommon "github.com/apache/incubator-answer/internal/service/answer_common"
@@ -32,7 +31,6 @@ import (
 	tagcommon "github.com/apache/incubator-answer/internal/service/tag_common"
 	"github.com/apache/incubator-answer/pkg/checker"
 	"github.com/apache/incubator-answer/pkg/obj"
-	"github.com/apache/incubator-answer/pkg/uid"
 	"github.com/segmentfault/pacman/errors"
 )
 
@@ -72,9 +70,6 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
 		if err != nil {
 			return nil, err
 		}
-		if handler.GetEnableShortID(ctx) {
-			questionInfo.ID = uid.EnShortID(questionInfo.ID)
-		}
 		if !exist {
 			break
 		}
@@ -118,9 +113,6 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
 		if !exist {
 			break
 		}
-		if handler.GetEnableShortID(ctx) {
-			questionInfo.ID = uid.EnShortID(questionInfo.ID)
-		}
 		objInfo = &schema.UnreviewedRevisionInfoInfo{
 			CreatedAt:           answerInfo.CreatedAt.Unix(),
 			ObjectID:            answerInfo.ID,