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

feat(artiment-auditon): pending for artiment #440

Merged
merged 10 commits into from
Nov 11, 2021
6 changes: 5 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ config :groupher_server, Helper.Scheduler,
jobs: [
# Every midnight
{"@daily", {Helper.Scheduler, :clear_all_cache, []}},
{"@daily", {Helper.Scheduler, :archive_artiments, []}}
{"@daily", {Helper.Scheduler, :archive_artiments, []}},
# Every 59 minutes
{"*/59 * * * *", {Helper.Scheduler, :articles_audition, []}},
# Every 29 minutes
{"*/29 * * * *", {Helper.Scheduler, :comments_audition, []}}
]

# handle background jobs
Expand Down
13 changes: 12 additions & 1 deletion lib/groupher_server/accounts/models/embeds/user_meta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserMeta do
reported_count: 0,
reported_user_ids: [],
follower_user_ids: [],
following_user_ids: []
following_user_ids: [],
# audit_artiment state
has_illegal_articles: false,
illegal_articles: [],
has_illegal_comments: false,
illegal_comments: []
}

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

field(:has_illegal_articles, :boolean, default: false)
field(:has_illegal_comments, :boolean, default: false)

field(:illegal_articles, {:array, :string}, default: [])
field(:illegal_comments, {:array, :string}, default: [])

published_article_count_fields()
end

Expand Down
61 changes: 37 additions & 24 deletions lib/groupher_server/cms/cms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule GroupherServer.CMS do
ArticleCommunity,
ArticleEmotion,
CitedArtiment,
CommentCurd,
CommentCURD,
ArticleCollect,
ArticleUpvote,
CommentAction,
Expand Down Expand Up @@ -86,9 +86,16 @@ defmodule GroupherServer.CMS do
defdelegate read_article(thread, id), to: ArticleCURD
defdelegate read_article(thread, id, user), to: ArticleCURD

defdelegate paged_articles(queryable, filter), to: ArticleCURD
defdelegate paged_articles(queryable, filter, user), to: ArticleCURD
defdelegate paged_published_articles(queryable, filter, user), to: ArticleCURD
defdelegate set_article_illegal(thread, id, attrs), to: ArticleCURD
defdelegate set_article_illegal(article, attrs), to: ArticleCURD
defdelegate unset_article_illegal(thread, id, attrs), to: ArticleCURD
defdelegate unset_article_illegal(article, attrs), to: ArticleCURD
defdelegate set_article_audit_failed(article, state), to: ArticleCURD

defdelegate paged_articles(thread, filter), to: ArticleCURD
defdelegate paged_articles(thread, filter, user), to: ArticleCURD
defdelegate paged_published_articles(thread, filter, user), to: ArticleCURD
defdelegate paged_audit_failed_articles(thread, filter), to: ArticleCURD

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

# Comment CURD

defdelegate comments_state(thread, article_id), to: CommentCurd
defdelegate comments_state(thread, article_id, user), to: CommentCurd
defdelegate one_comment(id), to: CommentCurd
defdelegate one_comment(id, user), to: CommentCurd
defdelegate set_comment_illegal(comment_id, attrs), to: CommentCURD
defdelegate unset_comment_illegal(comment_id, attrs), to: CommentCURD
defdelegate paged_audit_failed_comments(filter), to: CommentCURD

defdelegate set_comment_audit_failed(comment, state), to: CommentCURD

defdelegate comments_state(thread, article_id), to: CommentCURD
defdelegate comments_state(thread, article_id, user), to: CommentCURD
defdelegate one_comment(id), to: CommentCURD
defdelegate one_comment(id, user), to: CommentCURD

defdelegate update_user_in_comments_participants(user), to: CommentCurd
defdelegate paged_comments(thread, article_id, filters, mode), to: CommentCurd
defdelegate paged_comments(thread, article_id, filters, mode, user), to: CommentCurd
defdelegate update_user_in_comments_participants(user), to: CommentCURD
defdelegate paged_comments(thread, article_id, filters, mode), to: CommentCURD
defdelegate paged_comments(thread, article_id, filters, mode, user), to: CommentCURD

defdelegate paged_published_comments(user, thread, filters), to: CommentCurd
defdelegate paged_published_comments(user, filters), to: CommentCurd
defdelegate paged_published_comments(user, thread, filters), to: CommentCURD
defdelegate paged_published_comments(user, filters), to: CommentCURD

defdelegate paged_folded_comments(thread, article_id, filters), to: CommentCurd
defdelegate paged_folded_comments(thread, article_id, filters, user), to: CommentCurd
defdelegate paged_folded_comments(thread, article_id, filters), to: CommentCURD
defdelegate paged_folded_comments(thread, article_id, filters, user), to: CommentCURD

defdelegate paged_comment_replies(comment_id, filters), to: CommentCurd
defdelegate paged_comment_replies(comment_id, filters, user), to: CommentCurd
defdelegate paged_comment_replies(comment_id, filters), to: CommentCURD
defdelegate paged_comment_replies(comment_id, filters, user), to: CommentCURD

defdelegate paged_comments_participants(thread, content_id, filters), to: CommentCurd
defdelegate paged_comments_participants(thread, content_id, filters), to: CommentCURD

defdelegate create_comment(thread, article_id, args, user), to: CommentCurd
defdelegate update_comment(comment, content), to: CommentCurd
defdelegate delete_comment(comment), to: CommentCurd
defdelegate mark_comment_solution(comment, user), to: CommentCurd
defdelegate undo_mark_comment_solution(comment, user), to: CommentCurd
defdelegate create_comment(thread, article_id, args, user), to: CommentCURD
defdelegate update_comment(comment, content), to: CommentCURD
defdelegate delete_comment(comment), to: CommentCURD
defdelegate mark_comment_solution(comment, user), to: CommentCURD
defdelegate undo_mark_comment_solution(comment, user), to: CommentCURD

defdelegate archive_comments(), to: CommentCurd
defdelegate archive_comments(), to: CommentCURD

defdelegate upvote_comment(comment_id, user), to: CommentAction
defdelegate undo_upvote_comment(comment_id, user), to: CommentAction
Expand Down
14 changes: 14 additions & 0 deletions lib/groupher_server/cms/constant.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule GroupherServer.CMS.Constant do
@moduledoc """
constant used for CMS

NOTE: DO NOT modify, unless you know what you are doing
"""
@artiment_legal 0
@artiment_illegal 1
@artiment_audit_failed 2

def pending(:legal), do: @artiment_legal
def pending(:illegal), do: @artiment_illegal
def pending(:audit_failed), do: @artiment_audit_failed
end
Loading