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.

feat(review): update flag api response

LinkinStars557172d0d58f
diff --git a/docs/docs.go b/docs/docs.go
index 74f2b9df..9db1f742 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1,4 +1,5 @@
-// Package docs Code generated by swaggo/swag. DO NOT EDIT
+// Code generated by swaggo/swag. DO NOT EDIT.
+
package docs
import "github.com/swaggo/swag"
@@ -38,7 +39,7 @@ const docTemplate = `{
"ApiKeyAuth": []
}
],
- "description": "Status:[available,deleted,pending]",
+ "description": "ObjectStatus:[available,deleted,pending]",
"consumes": [
"application/json"
],
@@ -369,7 +370,7 @@ const docTemplate = `{
"ApiKeyAuth": []
}
],
- "description": "Status:[available,closed,deleted,pending]",
+ "description": "ObjectStatus:[available,closed,deleted,pending]",
"consumes": [
"application/json"
],
@@ -7821,34 +7822,39 @@ const docTemplate = `{
"schema.GetReportListPageResp": {
"type": "object",
"properties": {
- "_": {
- "type": "string"
- },
"answer_id": {
"type": "string"
},
- "comment_id": {
- "type": "string"
+ "author_user_info": {
+ "$ref": "#/definitions/schema.UserBasicInfo"
},
- "content": {
+ "comment_id": {
"type": "string"
},
"created_at": {
"type": "integer"
},
- "excerpt": {
+ "flag_id": {
"type": "string"
},
- "flagged_content": {
+ "object_id": {
"type": "string"
},
- "flagged_reason": {
- "$ref": "#/definitions/schema.ReasonItem"
+ "object_show_status": {
+ "type": "integer"
},
- "id": {
- "type": "string"
+ "object_status": {
+ "type": "integer"
},
"object_type": {
+ "type": "string",
+ "enum": [
+ "question",
+ "answer",
+ "comment"
+ ]
+ },
+ "original_text": {
"type": "string"
},
"question_id": {
@@ -7857,17 +7863,20 @@ const docTemplate = `{
"reason": {
"$ref": "#/definitions/schema.ReasonItem"
},
- "report_user": {
- "$ref": "#/definitions/schema.UserBasicInfo"
+ "submit_at": {
+ "type": "integer"
},
- "reported_user": {
+ "submitter_user": {
"$ref": "#/definitions/schema.UserBasicInfo"
},
+ "tags": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/schema.TagResp"
+ }
+ },
"title": {
"type": "string"
- },
- "updated_at": {
- "type": "integer"
}
}
},
@@ -8124,7 +8133,13 @@ const docTemplate = `{
"schema.GetUnreviewedPostPageResp": {
"type": "object",
"properties": {
- "author_user_id": {
+ "answer_id": {
+ "type": "string"
+ },
+ "author_user_info": {
+ "$ref": "#/definitions/schema.UserBasicInfo"
+ },
+ "comment_id": {
"type": "string"
},
"created_at": {
@@ -8133,6 +8148,12 @@ const docTemplate = `{
"object_id": {
"type": "string"
},
+ "object_show_status": {
+ "type": "integer"
+ },
+ "object_status": {
+ "type": "integer"
+ },
"object_type": {
"type": "string",
"enum": [
@@ -8141,7 +8162,13 @@ const docTemplate = `{
"comment"
]
},
- "parsed_text": {
+ "original_text": {
+ "type": "string"
+ },
+ "question_id": {
+ "type": "string"
+ },
+ "reason": {
"type": "string"
},
"review_id": {
@@ -8161,9 +8188,6 @@ const docTemplate = `{
},
"title": {
"type": "string"
- },
- "user_info": {
- "$ref": "#/definitions/schema.UserBasicInfo"
}
}
},
@@ -8931,7 +8955,7 @@ const docTemplate = `{
"type": "string"
},
"status": {
- "description": "Status",
+ "description": "ObjectStatus",
"type": "string"
},
"tags": {
@@ -9612,6 +9636,12 @@ const docTemplate = `{
"schema.UnreviewedRevisionInfoInfo": {
"type": "object",
"properties": {
+ "answer_id": {
+ "type": "string"
+ },
+ "comment_id": {
+ "type": "string"
+ },
"content": {
"type": "string"
},
@@ -9627,6 +9657,18 @@ const docTemplate = `{
"object_id": {
"type": "string"
},
+ "object_type": {
+ "type": "string"
+ },
+ "question_id": {
+ "type": "string"
+ },
+ "show_status": {
+ "type": "integer"
+ },
+ "status": {
+ "type": "integer"
+ },
"tags": {
"type": "array",
"items": {
diff --git a/docs/swagger.json b/docs/swagger.json
index c133e0c9..d7bf136c 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -27,7 +27,7 @@
"ApiKeyAuth": []
}
],
- "description": "Status:[available,deleted,pending]",
+ "description": "ObjectStatus:[available,deleted,pending]",
"consumes": [
"application/json"
],
@@ -358,7 +358,7 @@
"ApiKeyAuth": []
}
],
- "description": "Status:[available,closed,deleted,pending]",
+ "description": "ObjectStatus:[available,closed,deleted,pending]",
"consumes": [
"application/json"
],
@@ -7810,34 +7810,39 @@
"schema.GetReportListPageResp": {
"type": "object",
"properties": {
- "_": {
- "type": "string"
- },
"answer_id": {
"type": "string"
},
- "comment_id": {
- "type": "string"
+ "author_user_info": {
+ "$ref": "#/definitions/schema.UserBasicInfo"
},
- "content": {
+ "comment_id": {
"type": "string"
},
"created_at": {
"type": "integer"
},
- "excerpt": {
+ "flag_id": {
"type": "string"
},
- "flagged_content": {
+ "object_id": {
"type": "string"
},
- "flagged_reason": {
- "$ref": "#/definitions/schema.ReasonItem"
+ "object_show_status": {
+ "type": "integer"
},
- "id": {
- "type": "string"
+ "object_status": {
+ "type": "integer"
},
"object_type": {
+ "type": "string",
+ "enum": [
+ "question",
+ "answer",
+ "comment"
+ ]
+ },
+ "original_text": {
"type": "string"
},
"question_id": {
@@ -7846,17 +7851,20 @@
"reason": {
"$ref": "#/definitions/schema.ReasonItem"
},
- "report_user": {
- "$ref": "#/definitions/schema.UserBasicInfo"
+ "submit_at": {
+ "type": "integer"
},
- "reported_user": {
+ "submitter_user": {
"$ref": "#/definitions/schema.UserBasicInfo"
},
+ "tags": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/schema.TagResp"
+ }
+ },
"title": {
"type": "string"
- },
- "updated_at": {
- "type": "integer"
}
}
},
@@ -8113,7 +8121,13 @@
"schema.GetUnreviewedPostPageResp": {
"type": "object",
"properties": {
- "author_user_id": {
+ "answer_id": {
+ "type": "string"
+ },
+ "author_user_info": {
+ "$ref": "#/definitions/schema.UserBasicInfo"
+ },
+ "comment_id": {
"type": "string"
},
"created_at": {
@@ -8122,6 +8136,12 @@
"object_id": {
"type": "string"
},
+ "object_show_status": {
+ "type": "integer"
+ },
+ "object_status": {
+ "type": "integer"
+ },
"object_type": {
"type": "string",
"enum": [
@@ -8130,7 +8150,13 @@
"comment"
]
},
- "parsed_text": {
+ "original_text": {
+ "type": "string"
+ },
+ "question_id": {
+ "type": "string"
+ },
+ "reason": {
"type": "string"
},
"review_id": {
@@ -8150,9 +8176,6 @@
},
"title": {
"type": "string"
- },
- "user_info": {
- "$ref": "#/definitions/schema.UserBasicInfo"
}
}
},
@@ -8920,7 +8943,7 @@
"type": "string"
},
"status": {
- "description": "Status",
+ "description": "ObjectStatus",
"type": "string"
},
"tags": {
@@ -9601,6 +9624,12 @@
"schema.UnreviewedRevisionInfoInfo": {
"type": "object",
"properties": {
+ "answer_id": {
+ "type": "string"
+ },
+ "comment_id": {
+ "type": "string"
+ },
"content": {
"type": "string"
},
@@ -9616,6 +9645,18 @@
"object_id": {
"type": "string"
},
+ "object_type": {
+ "type": "string"
+ },
+ "question_id": {
+ "type": "string"
+ },
+ "show_status": {
+ "type": "integer"
+ },
+ "status": {
+ "type": "integer"
+ },
"tags": {
"type": "array",
"items": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 8d5e305a..937cd78e 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -821,38 +821,44 @@ definitions:
type: object
schema.GetReportListPageResp:
properties:
- _:
- type: string
answer_id:
type: string
+ author_user_info:
+ $ref: '#/definitions/schema.UserBasicInfo'
comment_id:
type: string
- content:
- type: string
created_at:
type: integer
- excerpt:
- type: string
- flagged_content:
+ flag_id:
type: string
- flagged_reason:
- $ref: '#/definitions/schema.ReasonItem'
- id:
+ object_id:
type: string
+ object_show_status:
+ type: integer
+ object_status:
+ type: integer
object_type:
+ enum:
+ - question
+ - answer
+ - comment
+ type: string
+ original_text:
type: string
question_id:
type: string
reason:
$ref: '#/definitions/schema.ReasonItem'
- report_user:
- $ref: '#/definitions/schema.UserBasicInfo'
- reported_user:
+ submit_at:
+ type: integer
+ submitter_user:
$ref: '#/definitions/schema.UserBasicInfo'
+ tags:
+ items:
+ $ref: '#/definitions/schema.TagResp'
+ type: array
title:
type: string
- updated_at:
- type: integer
type: object
schema.GetReviewingTypeResp:
properties:
@@ -1028,19 +1034,31 @@ definitions:
type: object
schema.GetUnreviewedPostPageResp:
properties:
- author_user_id:
+ answer_id:
+ type: string
+ author_user_info:
+ $ref: '#/definitions/schema.UserBasicInfo'
+ comment_id:
type: string
created_at:
type: integer
object_id:
type: string
+ object_show_status:
+ type: integer
+ object_status:
+ type: integer
object_type:
enum:
- question
- answer
- comment
type: string
- parsed_text:
+ original_text:
+ type: string
+ question_id:
+ type: string
+ reason:
type: string
review_id:
type: integer
@@ -1054,8 +1072,6 @@ definitions:
type: array
title:
type: string
- user_info:
- $ref: '#/definitions/schema.UserBasicInfo'
type: object
schema.GetUnreviewedRevisionResp:
properties:
@@ -1589,7 +1605,7 @@ definitions:
question_id:
type: string
status:
- description: Status
+ description: ObjectStatus
type: string
tags:
description: tags
@@ -2053,6 +2069,10 @@ definitions:
type: object
schema.UnreviewedRevisionInfoInfo:
properties:
+ answer_id:
+ type: string
+ comment_id:
+ type: string
content:
type: string
created_at:
@@ -2063,6 +2083,14 @@ definitions:
type: string
object_id:
type: string
+ object_type:
+ type: string
+ question_id:
+ type: string
+ show_status:
+ type: integer
+ status:
+ type: integer
tags:
items:
$ref: '#/definitions/schema.TagResp'
@@ -2611,7 +2639,7 @@ paths:
get:
consumes:
- application/json
- description: Status:[available,deleted,pending]
+ description: ObjectStatus:[available,deleted,pending]
parameters:
- description: page size
in: query
@@ -2813,7 +2841,7 @@ paths:
get:
consumes:
- application/json
- description: Status:[available,closed,deleted,pending]
+ description: ObjectStatus:[available,closed,deleted,pending]
parameters:
- description: page size
in: query
diff --git a/internal/schema/report_schema.go b/internal/schema/report_schema.go
index 45becee4..6b15a1e0 100644
--- a/internal/schema/report_schema.go
+++ b/internal/schema/report_schema.go
@@ -19,12 +19,6 @@
package schema
-import (
- "time"
-
- "github.com/apache/incubator-answer/internal/base/constant"
-)
-
// AddReportReq add report request
type AddReportReq struct {
// object id
@@ -77,45 +71,22 @@ type GetReportListPageDTO struct {
// GetReportListPageResp get report list
type GetReportListPageResp struct {
- ID string `json:"id"`
- ReportedUser *UserBasicInfo `json:"reported_user"`
- ReportUser *UserBasicInfo `json:"report_user"`
-
- Content string `json:"content"`
- FlaggedContent string `json:"flagged_content"`
- OType string `json:"object_type"`
-
- ObjectID string `json:"-"`
- QuestionID string `json:"question_id"`
- AnswerID string `json:"answer_id"`
- CommentID string `json:"comment_id"`
-
- Title string `json:"title"`
- Excerpt string `json:"excerpt"`
-
- // create time
- CreatedAt time.Time `json:"-"`
- CreatedAtParsed int64 `json:"created_at"`
-
- UpdatedAt time.Time `json:"_"`
- UpdatedAtParsed int64 `json:"updated_at"`
-
- Reason *ReasonItem `json:"reason"`
- FlaggedReason *ReasonItem `json:"flagged_reason"`
-
- UserID string `json:"-"`
- ReportedUserID string `json:"-"`
- ObjectType int `json:"-"`
- ReportType int `json:"-"`
- FlaggedType int `json:"-"`
-}
-
-// Format format result
-func (r *GetReportListPageResp) Format() {
- r.OType = constant.ObjectTypeNumberMapping[r.ObjectType]
-
- r.CreatedAtParsed = r.CreatedAt.Unix()
- r.UpdatedAtParsed = r.UpdatedAt.Unix()
+ FlagID string `json:"flag_id"`
+ CreatedAt int64 `json:"created_at"`
+ ObjectID string `json:"object_id"`
+ QuestionID string `json:"question_id"`
+ AnswerID string `json:"answer_id"`
+ CommentID string `json:"comment_id"`
+ ObjectType string `json:"object_type" enums:"question,answer,comment"`
+ Title string `json:"title"`
+ OriginalText string `json:"original_text"`
+ Tags []*TagResp `json:"tags"`
+ ObjectStatus int `json:"object_status"`
+ ObjectShowStatus int `json:"object_show_status"`
+ AuthorUserInfo UserBasicInfo `json:"author_user_info"`
+ SubmitAt int64 `json:"submit_at"`
+ SubmitterUser UserBasicInfo `json:"submitter_user"`
+ Reason *ReasonItem `json:"reason"`
}
// GetUnreviewedReportPostPageReq get unreviewed report post page request
diff --git a/internal/schema/review_schema.go b/internal/schema/review_schema.go
index f76253c5..bda52204 100644
--- a/internal/schema/review_schema.go
+++ b/internal/schema/review_schema.go
@@ -41,12 +41,17 @@ type GetUnreviewedPostPageResp struct {
ReviewID int `json:"review_id"`
CreatedAt int64 `json:"created_at"`
ObjectID string `json:"object_id"`
+ QuestionID string `json:"question_id"`
+ AnswerID string `json:"answer_id"`
+ CommentID string `json:"comment_id"`
ObjectType string `json:"object_type" enums:"question,answer,comment"`
Title string `json:"title"`
- ParsedText string `json:"parsed_text"`
+ OriginalText string `json:"original_text"`
Tags []*TagResp `json:"tags"`
- AuthorUserID string `json:"author_user_id"`
- UserInfo UserBasicInfo `json:"user_info"`
+ ObjectStatus int `json:"object_status"`
+ ObjectShowStatus int `json:"object_show_status"`
+ AuthorUserInfo UserBasicInfo `json:"author_user_info"`
SubmitAt int64 `json:"submit_at"`
SubmitterDisplayName string `json:"submitter_display_name"`
+ Reason string `json:"reason"`
}
diff --git a/internal/schema/search_schema.go b/internal/schema/search_schema.go
index 90b08ceb..c64e9c76 100644
--- a/internal/schema/search_schema.go
+++ b/internal/schema/search_schema.go
@@ -20,11 +20,12 @@
package schema
import (
+ "regexp"
+ "strings"
+
"github.com/apache/incubator-answer/internal/base/constant"
"github.com/apache/incubator-answer/internal/base/validator"
"github.com/apache/incubator-answer/plugin"
- "regexp"
- "strings"
)
type SearchDTO struct {
diff --git a/internal/schema/simple_obj_info_schema.go b/internal/schema/simple_obj_info_schema.go
index 2c20d63b..56eb5549 100644
--- a/internal/schema/simple_obj_info_schema.go
+++ b/internal/schema/simple_obj_info_schema.go
@@ -36,9 +36,15 @@ type SimpleObjectInfo struct {
type UnreviewedRevisionInfoInfo struct {
CreatedAt int64 `json:"created_at"`
ObjectID string `json:"object_id"`
+ QuestionID string `json:"question_id"`
+ AnswerID string `json:"answer_id"`
+ CommentID string `json:"comment_id"`
+ ObjectType string `json:"object_type"`
ObjectCreatorUserID string `json:"object_creator_user_id"`
Title string `json:"title"`
Content string `json:"content"`
Html string `json:"html"`
Tags []*TagResp `json:"tags"`
+ Status int `json:"status"`
+ ShowStatus int `json:"show_status"`
}
diff --git a/internal/service/object_info/object_info.go b/internal/service/object_info/object_info.go
index 43f87743..719335de 100644
--- a/internal/service/object_info/object_info.go
+++ b/internal/service/object_info/object_info.go
@@ -89,11 +89,15 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
objInfo = &schema.UnreviewedRevisionInfoInfo{
CreatedAt: questionInfo.CreatedAt.Unix(),
ObjectID: questionInfo.ID,
+ QuestionID: questionInfo.ID,
+ ObjectType: objectType,
ObjectCreatorUserID: questionInfo.UserID,
Title: questionInfo.Title,
Content: questionInfo.OriginalText,
Html: questionInfo.ParsedText,
Tags: tags,
+ Status: questionInfo.Status,
+ ShowStatus: questionInfo.Show,
}
case constant.AnswerObjectType:
answerInfo, exist, err := os.answerRepo.GetAnswer(ctx, objectID)
@@ -117,10 +121,14 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
objInfo = &schema.UnreviewedRevisionInfoInfo{
CreatedAt: answerInfo.CreatedAt.Unix(),
ObjectID: answerInfo.ID,
+ QuestionID: answerInfo.QuestionID,
+ AnswerID: answerInfo.ID,
+ ObjectType: objectType,
ObjectCreatorUserID: answerInfo.UserID,
Title: questionInfo.Title,
Content: answerInfo.OriginalText,
Html: answerInfo.ParsedText,
+ Status: answerInfo.Status,
}
case constant.TagObjectType:
tagInfo, exist, err := os.tagRepo.GetTagByID(ctx, objectID, true)
@@ -131,11 +139,13 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
break
}
objInfo = &schema.UnreviewedRevisionInfoInfo{
- CreatedAt: tagInfo.CreatedAt.Unix(),
- ObjectID: tagInfo.ID,
- Title: tagInfo.SlugName,
- Content: tagInfo.OriginalText,
- Html: tagInfo.ParsedText,
+ CreatedAt: tagInfo.CreatedAt.Unix(),
+ ObjectID: tagInfo.ID,
+ ObjectType: objectType,
+ Title: tagInfo.SlugName,
+ Content: tagInfo.OriginalText,
+ Html: tagInfo.ParsedText,
+ Status: tagInfo.Status,
}
case constant.CommentObjectType:
commentInfo, exist, err := os.commentRepo.GetComment(ctx, objectID)
@@ -148,9 +158,28 @@ func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID st
objInfo = &schema.UnreviewedRevisionInfoInfo{
CreatedAt: commentInfo.CreatedAt.Unix(),
ObjectID: commentInfo.ID,
+ CommentID: commentInfo.ID,
+ ObjectType: objectType,
ObjectCreatorUserID: commentInfo.UserID,
Content: commentInfo.OriginalText,
Html: commentInfo.ParsedText,
+ Status: commentInfo.Status,
+ }
+ if len(commentInfo.QuestionID) > 0 {
+ questionInfo, exist, err := os.questionRepo.GetQuestion(ctx, commentInfo.QuestionID)
+ if err != nil {
+ return nil, err
+ }
+ if exist {
+ objInfo.QuestionID = questionInfo.ID
+ }
+ answerInfo, exist, err := os.answerRepo.GetAnswer(ctx, commentInfo.ObjectID)
+ if err != nil {
+ return nil, err
+ }
+ if exist {
+ objInfo.AnswerID = answerInfo.ID
+ }
}
}
if objInfo == nil {
diff --git a/internal/service/report/report_service.go b/internal/service/report/report_service.go
index 72ea83bf..b5af3211 100644
--- a/internal/service/report/report_service.go
+++ b/internal/service/report/report_service.go
@@ -36,7 +36,6 @@ import (
"github.com/apache/incubator-answer/internal/service/report_common"
"github.com/apache/incubator-answer/internal/service/report_handle"
usercommon "github.com/apache/incubator-answer/internal/service/user_common"
- "github.com/apache/incubator-answer/pkg/htmltext"
"github.com/apache/incubator-answer/pkg/obj"
"github.com/jinzhu/copier"
"github.com/segmentfault/pacman/errors"
@@ -107,6 +106,7 @@ func (rs *ReportService) AddReport(ctx context.Context, req *schema.AddReportReq
// GetUnreviewedReportPostPage get unreviewed report post page
func (rs *ReportService) GetUnreviewedReportPostPage(ctx context.Context, req *schema.GetUnreviewedReportPostPageReq) (
pageModel *pager.PageModel, err error) {
+ lang := handler.GetLangByCtx(ctx)
reports, total, err := rs.reportRepo.GetReportListPage(ctx, &schema.GetReportListPageDTO{
Page: req.Page,
PageSize: 1,
@@ -117,29 +117,58 @@ func (rs *ReportService) GetUnreviewedReportPostPage(ctx context.Context, req *s
}
resp := make([]*schema.GetReportListPageResp, 0)
- _ = copier.Copy(&resp, reports)
- var flaggedUserIds, userIds []string
- for _, r := range resp {
- flaggedUserIds = append(flaggedUserIds, r.ReportedUserID)
- userIds = append(userIds, r.UserID)
- r.Format()
- }
+ for _, report := range reports {
+ info, err := rs.objectInfoService.GetUnreviewedRevisionInfo(ctx, report.ObjectID)
+ if err != nil {
+ log.Errorf("GetUnreviewedRevisionInfo failed, err: %v", err)
+ continue
+ }
- // flagged users
- flaggedUsers, err := rs.commonUser.BatchUserBasicInfoByID(ctx, flaggedUserIds)
- if err != nil {
- return nil, err
- }
+ r := &schema.GetReportListPageResp{
+ FlagID: report.ID,
+ CreatedAt: info.CreatedAt,
+ ObjectID: info.ObjectID,
+ ObjectType: info.ObjectType,
+ QuestionID: info.QuestionID,
+ AnswerID: info.AnswerID,
+ CommentID: info.CommentID,
+ Title: info.Title,
+ OriginalText: info.Content,
+ Tags: info.Tags,
+ SubmitAt: report.CreatedAt.Unix(),
+ ObjectStatus: info.Status,
+ ObjectShowStatus: info.ShowStatus,
+ }
- // flag users
- users, err := rs.commonUser.BatchUserBasicInfoByID(ctx, userIds)
- if err != nil {
- return nil, err
- }
- for _, r := range resp {
- r.ReportedUser = flaggedUsers[r.ReportedUserID]
- r.ReportUser = users[r.UserID]
- rs.decorateReportResp(ctx, r)
+ // get user info
+ userInfo, exists, e := rs.commonUser.GetUserBasicInfoByID(ctx, info.ObjectCreatorUserID)
+ if e != nil {
+ log.Errorf("user not found by id: %s, err: %v", info.ObjectCreatorUserID, e)
+ }
+ if exists {
+ _ = copier.Copy(&r.AuthorUserInfo, userInfo)
+ }
+
+ // get submitter info
+ submitter, exists, e := rs.commonUser.GetUserBasicInfoByID(ctx, report.ReportedUserID)
+ if e != nil {
+ log.Errorf("user not found by id: %s, err: %v", info.ObjectCreatorUserID, e)
+ }
+ if exists {
+ _ = copier.Copy(&r.SubmitterUser, submitter)
+ }
+
+ if report.ReportType > 0 {
+ r.Reason = &schema.ReasonItem{ReasonType: report.ReportType}
+ cf, err := rs.configService.GetConfigByID(ctx, report.ReportType)
+ if err != nil {
+ log.Error(err)
+ } else {
+ _ = json.Unmarshal([]byte(cf.Value), r.Reason)
+ r.Reason.Translate(cf.Key, lang)
+ }
+ }
+ resp = append(resp, r)
}
return pager.NewPageModel(total, resp), nil
}
@@ -169,39 +198,3 @@ func (rs *ReportService) ReviewReport(ctx context.Context, req *schema.ReviewRep
return rs.reportRepo.UpdateStatus(ctx, report.ID, entity.ReportStatusCompleted)
}
-
-func (rs *ReportService) decorateReportResp(ctx context.Context, resp *schema.GetReportListPageResp) {
- lang := handler.GetLangByCtx(ctx)
- objectInfo, err := rs.objectInfoService.GetInfo(ctx, resp.ObjectID)
- if err != nil {
- log.Error(err)
- return
- }
-
- resp.QuestionID = objectInfo.QuestionID
- resp.AnswerID = objectInfo.AnswerID
- resp.CommentID = objectInfo.CommentID
- resp.Title = objectInfo.Title
- resp.Excerpt = htmltext.FetchExcerpt(objectInfo.Content, "...", 240)
-
- if resp.ReportType > 0 {
- resp.Reason = &schema.ReasonItem{ReasonType: resp.ReportType}
- cf, err := rs.configService.GetConfigByID(ctx, resp.ReportType)
- if err != nil {
- log.Error(err)
- } else {
- _ = json.Unmarshal([]byte(cf.Value), resp.Reason)
- resp.Reason.Translate(cf.Key, lang)
- }
- }
- if resp.FlaggedType > 0 {
- resp.FlaggedReason = &schema.ReasonItem{ReasonType: resp.FlaggedType}
- cf, err := rs.configService.GetConfigByID(ctx, resp.FlaggedType)
- if err != nil {
- log.Error(err)
- } else {
- _ = json.Unmarshal([]byte(cf.Value), resp.Reason)
- resp.Reason.Translate(cf.Key, lang)
- }
- }
-}
diff --git a/internal/service/review/review_service.go b/internal/service/review/review_service.go
index e0a713fe..354eb972 100644
--- a/internal/service/review/review_service.go
+++ b/internal/service/review/review_service.go
@@ -247,13 +247,18 @@ func (cs *ReviewService) GetUnreviewedPostPage(ctx context.Context, req *schema.
ReviewID: review.ID,
CreatedAt: info.CreatedAt,
ObjectID: info.ObjectID,
- ObjectType: info.ObjectID,
+ QuestionID: info.QuestionID,
+ AnswerID: info.AnswerID,
+ CommentID: info.CommentID,
+ ObjectType: info.ObjectType,
Title: info.Title,
- ParsedText: info.Html,
+ OriginalText: info.Content,
Tags: info.Tags,
- AuthorUserID: info.ObjectCreatorUserID,
+ ObjectStatus: info.Status,
+ ObjectShowStatus: info.ShowStatus,
SubmitAt: review.CreatedAt.Unix(),
SubmitterDisplayName: req.ReviewerMapping[review.Submitter],
+ Reason: review.Reason,
}
// get user info
@@ -262,7 +267,7 @@ func (cs *ReviewService) GetUnreviewedPostPage(ctx context.Context, req *schema.
log.Errorf("user not found by id: %s, err: %v", info.ObjectCreatorUserID, e)
}
if exists {
- _ = copier.Copy(&r.UserInfo, userInfo)
+ _ = copier.Copy(&r.AuthorUserInfo, userInfo)
}
resp = append(resp, r)
}