Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 66c4062

Browse files
authored
feat(artiment-auditon): pending for artiment (#440)
* refactor(pending-state): basic flag for articles * refactor(pending-state): pasic set/unset operate * refactor(pending-state): basic legal/illegal workflow for articles * refactor(pending): test re-org, fix edge case * refactor(pending): audition hook for article * refactor(audit-hooks): add comment support, more tests * refactor(audit-hooks): enhance with cron job & more tests * refactor(comment): test with audit meta * fix(repo): missing pending field * fix: test error
1 parent f57dd92 commit 66c4062

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1938
-93
lines changed

config/config.exs

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ config :groupher_server, Helper.Scheduler,
158158
jobs: [
159159
# Every midnight
160160
{"@daily", {Helper.Scheduler, :clear_all_cache, []}},
161-
{"@daily", {Helper.Scheduler, :archive_artiments, []}}
161+
{"@daily", {Helper.Scheduler, :archive_artiments, []}},
162+
# Every 59 minutes
163+
{"*/59 * * * *", {Helper.Scheduler, :articles_audition, []}},
164+
# Every 29 minutes
165+
{"*/29 * * * *", {Helper.Scheduler, :comments_audition, []}}
162166
]
163167

164168
# handle background jobs

lib/groupher_server/accounts/models/embeds/user_meta.ex

+12-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserMeta do
3333
reported_count: 0,
3434
reported_user_ids: [],
3535
follower_user_ids: [],
36-
following_user_ids: []
36+
following_user_ids: [],
37+
# audit_artiment state
38+
has_illegal_articles: false,
39+
illegal_articles: [],
40+
has_illegal_comments: false,
41+
illegal_comments: []
3742
}
3843

3944
@optional_fields Map.keys(@general_options) ++
@@ -58,6 +63,12 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserMeta do
5863
field(:follower_user_ids, {:array, :integer}, default: [])
5964
field(:following_user_ids, {:array, :integer}, default: [])
6065

66+
field(:has_illegal_articles, :boolean, default: false)
67+
field(:has_illegal_comments, :boolean, default: false)
68+
69+
field(:illegal_articles, {:array, :string}, default: [])
70+
field(:illegal_comments, {:array, :string}, default: [])
71+
6172
published_article_count_fields()
6273
end
6374

lib/groupher_server/cms/cms.ex

+37-24
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule GroupherServer.CMS do
1515
ArticleCommunity,
1616
ArticleEmotion,
1717
CitedArtiment,
18-
CommentCurd,
18+
CommentCURD,
1919
ArticleCollect,
2020
ArticleUpvote,
2121
CommentAction,
@@ -86,9 +86,16 @@ defmodule GroupherServer.CMS do
8686
defdelegate read_article(thread, id), to: ArticleCURD
8787
defdelegate read_article(thread, id, user), to: ArticleCURD
8888

89-
defdelegate paged_articles(queryable, filter), to: ArticleCURD
90-
defdelegate paged_articles(queryable, filter, user), to: ArticleCURD
91-
defdelegate paged_published_articles(queryable, filter, user), to: ArticleCURD
89+
defdelegate set_article_illegal(thread, id, attrs), to: ArticleCURD
90+
defdelegate set_article_illegal(article, attrs), to: ArticleCURD
91+
defdelegate unset_article_illegal(thread, id, attrs), to: ArticleCURD
92+
defdelegate unset_article_illegal(article, attrs), to: ArticleCURD
93+
defdelegate set_article_audit_failed(article, state), to: ArticleCURD
94+
95+
defdelegate paged_articles(thread, filter), to: ArticleCURD
96+
defdelegate paged_articles(thread, filter, user), to: ArticleCURD
97+
defdelegate paged_published_articles(thread, filter, user), to: ArticleCURD
98+
defdelegate paged_audit_failed_articles(thread, filter), to: ArticleCURD
9299

93100
defdelegate create_article(community, thread, attrs, user), to: ArticleCURD
94101
defdelegate update_article(article, attrs), to: ArticleCURD
@@ -153,33 +160,39 @@ defmodule GroupherServer.CMS do
153160

154161
# Comment CURD
155162

156-
defdelegate comments_state(thread, article_id), to: CommentCurd
157-
defdelegate comments_state(thread, article_id, user), to: CommentCurd
158-
defdelegate one_comment(id), to: CommentCurd
159-
defdelegate one_comment(id, user), to: CommentCurd
163+
defdelegate set_comment_illegal(comment_id, attrs), to: CommentCURD
164+
defdelegate unset_comment_illegal(comment_id, attrs), to: CommentCURD
165+
defdelegate paged_audit_failed_comments(filter), to: CommentCURD
166+
167+
defdelegate set_comment_audit_failed(comment, state), to: CommentCURD
168+
169+
defdelegate comments_state(thread, article_id), to: CommentCURD
170+
defdelegate comments_state(thread, article_id, user), to: CommentCURD
171+
defdelegate one_comment(id), to: CommentCURD
172+
defdelegate one_comment(id, user), to: CommentCURD
160173

161-
defdelegate update_user_in_comments_participants(user), to: CommentCurd
162-
defdelegate paged_comments(thread, article_id, filters, mode), to: CommentCurd
163-
defdelegate paged_comments(thread, article_id, filters, mode, user), to: CommentCurd
174+
defdelegate update_user_in_comments_participants(user), to: CommentCURD
175+
defdelegate paged_comments(thread, article_id, filters, mode), to: CommentCURD
176+
defdelegate paged_comments(thread, article_id, filters, mode, user), to: CommentCURD
164177

165-
defdelegate paged_published_comments(user, thread, filters), to: CommentCurd
166-
defdelegate paged_published_comments(user, filters), to: CommentCurd
178+
defdelegate paged_published_comments(user, thread, filters), to: CommentCURD
179+
defdelegate paged_published_comments(user, filters), to: CommentCURD
167180

168-
defdelegate paged_folded_comments(thread, article_id, filters), to: CommentCurd
169-
defdelegate paged_folded_comments(thread, article_id, filters, user), to: CommentCurd
181+
defdelegate paged_folded_comments(thread, article_id, filters), to: CommentCURD
182+
defdelegate paged_folded_comments(thread, article_id, filters, user), to: CommentCURD
170183

171-
defdelegate paged_comment_replies(comment_id, filters), to: CommentCurd
172-
defdelegate paged_comment_replies(comment_id, filters, user), to: CommentCurd
184+
defdelegate paged_comment_replies(comment_id, filters), to: CommentCURD
185+
defdelegate paged_comment_replies(comment_id, filters, user), to: CommentCURD
173186

174-
defdelegate paged_comments_participants(thread, content_id, filters), to: CommentCurd
187+
defdelegate paged_comments_participants(thread, content_id, filters), to: CommentCURD
175188

176-
defdelegate create_comment(thread, article_id, args, user), to: CommentCurd
177-
defdelegate update_comment(comment, content), to: CommentCurd
178-
defdelegate delete_comment(comment), to: CommentCurd
179-
defdelegate mark_comment_solution(comment, user), to: CommentCurd
180-
defdelegate undo_mark_comment_solution(comment, user), to: CommentCurd
189+
defdelegate create_comment(thread, article_id, args, user), to: CommentCURD
190+
defdelegate update_comment(comment, content), to: CommentCURD
191+
defdelegate delete_comment(comment), to: CommentCURD
192+
defdelegate mark_comment_solution(comment, user), to: CommentCURD
193+
defdelegate undo_mark_comment_solution(comment, user), to: CommentCURD
181194

182-
defdelegate archive_comments(), to: CommentCurd
195+
defdelegate archive_comments(), to: CommentCURD
183196

184197
defdelegate upvote_comment(comment_id, user), to: CommentAction
185198
defdelegate undo_upvote_comment(comment_id, user), to: CommentAction

lib/groupher_server/cms/constant.ex

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defmodule GroupherServer.CMS.Constant do
2+
@moduledoc """
3+
constant used for CMS
4+
5+
NOTE: DO NOT modify, unless you know what you are doing
6+
"""
7+
@artiment_legal 0
8+
@artiment_illegal 1
9+
@artiment_audit_failed 2
10+
11+
def pending(:legal), do: @artiment_legal
12+
def pending(:illegal), do: @artiment_illegal
13+
def pending(:audit_failed), do: @artiment_audit_failed
14+
end

0 commit comments

Comments
 (0)