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

kumfo pushed a commit to branch feat/reviewer-basic
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git


The following commit(s) were added to refs/heads/feat/reviewer-basic by this 
push:
     new 4ba80cb  feat(review): add review all post option
4ba80cb is described below

commit 4ba80cbccf8df131271d9d072809dfe900a5cd18
Author: kumfo <[email protected]>
AuthorDate: Wed Apr 24 14:43:22 2024 +0800

    feat(review): add review all post option
---
 reviewer-basic/basic.go            | 32 ++++++++++++++++++++++++++------
 reviewer-basic/i18n/en_US.yaml     | 10 ++++++----
 reviewer-basic/i18n/translation.go |  3 ++-
 reviewer-basic/i18n/zh_CN.yaml     | 10 ++++++----
 4 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/reviewer-basic/basic.go b/reviewer-basic/basic.go
index 53521be..001ef67 100644
--- a/reviewer-basic/basic.go
+++ b/reviewer-basic/basic.go
@@ -35,6 +35,7 @@ type Reviewer struct {
 }
 
 type ReviewerConfig struct {
+       PostAllNeedReview      bool   `json:"review_post_all"`
        PostNeedReview         bool   `json:"review_post"`
        PostReviewKeywords     string `json:"review_post_keywords"`
        PostDisallowedKeywords string `json:"disallowed_keywords"`
@@ -59,8 +60,14 @@ func (r *Reviewer) Info() plugin.Info {
 
 func (r *Reviewer) Review(content *plugin.ReviewContent) (result 
*plugin.ReviewResult) {
        result = &plugin.ReviewResult{Approved: true, ReviewStatus: 
plugin.ReviewStatusApproved}
-       // this switch is true and have any other approved post, return directly
-       if r.Config.PostNeedReview && 
content.Author.ApprovedQuestionAmount+content.Author.ApprovedAnswerAmount == 0 {
+
+       // If the author is admin, no need to review
+       if content.Author.Role > 1 {
+               return result
+       }
+
+       // all post need review
+       if r.Config.PostAllNeedReview {
                result = &plugin.ReviewResult{
                        Approved:     false,
                        ReviewStatus: plugin.ReviewStatusNeedReview,
@@ -69,8 +76,13 @@ func (r *Reviewer) Review(content *plugin.ReviewContent) 
(result *plugin.ReviewR
                return result
        }
 
-       // If the author is admin, no need to review
-       if content.Author.Role > 1 {
+       // this switch is true and have any other approved post, return directly
+       if r.Config.PostNeedReview && 
content.Author.ApprovedQuestionAmount+content.Author.ApprovedAnswerAmount == 0 {
+               result = &plugin.ReviewResult{
+                       Approved:     false,
+                       ReviewStatus: plugin.ReviewStatusNeedReview,
+                       Reason:       
plugin.TranslateWithData(myI18n.Language(content.Language), 
i18n.CommentNeedReview, nil),
+               }
                return result
        }
 
@@ -118,13 +130,21 @@ func (r *Reviewer) Review(content *plugin.ReviewContent) 
(result *plugin.ReviewR
 
 func (r *Reviewer) ConfigFields() []plugin.ConfigField {
        return []plugin.ConfigField{
+               {
+                       Name:  "review_all_post",
+                       Type:  plugin.ConfigTypeSwitch,
+                       Title: 
plugin.MakeTranslator(i18n.ConfigReviewPostTitle),
+                       UIOptions: plugin.ConfigFieldUIOptions{
+                               Label: 
plugin.MakeTranslator(i18n.ConfigReviewPostLabelAll),
+                       },
+                       Value: r.Config.PostAllNeedReview,
+               },
                {
                        Name:        "review_post",
                        Type:        plugin.ConfigTypeSwitch,
-                       Title:       
plugin.MakeTranslator(i18n.ConfigReviewPostTitle),
                        Description: 
plugin.MakeTranslator(i18n.ConfigReviewPostDescription),
                        UIOptions: plugin.ConfigFieldUIOptions{
-                               Label: 
plugin.MakeTranslator(i18n.ConfigReviewPostLabel),
+                               Label: 
plugin.MakeTranslator(i18n.ConfigReviewPostLabelFirst),
                        },
                        Value: r.Config.PostNeedReview,
                },
diff --git a/reviewer-basic/i18n/en_US.yaml b/reviewer-basic/i18n/en_US.yaml
index a7c717b..2971d62 100644
--- a/reviewer-basic/i18n/en_US.yaml
+++ b/reviewer-basic/i18n/en_US.yaml
@@ -26,11 +26,13 @@ plugin:
       config:
         review_post:
           title:
-            other: Review question and answer
-          label:
-            other: Review post when author do not have any other approved post
+            other: Before a post appears
+          label_all:
+            other: Post must be manually approved
+          label_first:
+            other: Post author must have a previously approved post
           description:
-            other: Questions or answers are not visible until they are 
approved.
+            other: Questions or answers will be held in the review queue and 
will not be visible until they are approved.
         review_post_keywords:
           title:
             other: Review post keywords
diff --git a/reviewer-basic/i18n/translation.go 
b/reviewer-basic/i18n/translation.go
index b3d2623..1289fbc 100644
--- a/reviewer-basic/i18n/translation.go
+++ b/reviewer-basic/i18n/translation.go
@@ -22,7 +22,8 @@ package i18n
 const (
        InfoName                            = 
"plugin.basic_reviewer.backend.info.name"
        InfoDescription                     = 
"plugin.basic_reviewer.backend.info.description"
-       ConfigReviewPostLabel               = 
"plugin.basic_reviewer.backend.config.review_post.label"
+       ConfigReviewPostLabelAll            = 
"plugin.basic_reviewer.backend.config.review_post.label_all"
+       ConfigReviewPostLabelFirst          = 
"plugin.basic_reviewer.backend.config.review_post.label_first"
        ConfigReviewPostTitle               = 
"plugin.basic_reviewer.backend.config.review_post.title"
        ConfigReviewPostDescription         = 
"plugin.basic_reviewer.backend.config.review_post.description"
        ConfigReviewPostKeywordsTitle       = 
"plugin.basic_reviewer.backend.config.review_post_keywords.title"
diff --git a/reviewer-basic/i18n/zh_CN.yaml b/reviewer-basic/i18n/zh_CN.yaml
index 306e954..4d047a7 100644
--- a/reviewer-basic/i18n/zh_CN.yaml
+++ b/reviewer-basic/i18n/zh_CN.yaml
@@ -26,11 +26,13 @@ plugin:
       config:
         review_post:
           title:
-            other: 审核问题和回答
-          label:
-            other: 当该作者没有任何已批准的问答内容时,他发布的问答内容需要审核
+            other: 帖子发布之前
+          label_all:
+            other: 所有帖子必须手动审核
+          label_first:
+            other: 内容发布者必须要有通过审核的帖子
           description:
-            other: 问题或回答在被批准之前是不可见的。
+            other: 问题或答案将保存在审查队列中,在获得批准之前不可见。
         review_post_keywords:
           title:
             other: 审核帖子关键词

Reply via email to