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

Commit ab568c1

Browse files
committed
refactor(abuse-report): wip
1 parent af7ec63 commit ab568c1

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

lib/groupher_server/cms/cms.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ defmodule GroupherServer.CMS do
156156
defdelegate list_comments_participators(thread, content_id, filters), to: CommentCURD
157157

158158
# TODO: move report to abuse report module
159-
defdelegate create_report(type, content_id, reason, attr, user), to: AbuseReport
160159
defdelegate report_article(thread, article_id, reason, attr, user), to: AbuseReport
161160
defdelegate report_article_comment(comment_id, reason, attr, user), to: AbuseReport
162161
defdelegate report_account(account_id, reason, attr, user), to: AbuseReport

lib/groupher_server/cms/delegates/abuse_report.ex

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,6 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
9999
do_list_reports(query, filter)
100100
end
101101

102-
defp do_list_reports(query, thread, filter) do
103-
%{page: page, size: size} = filter
104-
105-
query
106-
|> QueryBuilder.filter_pack(filter)
107-
|> ORM.paginater(~m(page size)a)
108-
|> reports_formater(thread)
109-
|> done()
110-
end
111-
112-
defp do_list_reports(query, %{page: page, size: size}) do
113-
query |> ORM.paginater(~m(page size)a) |> done()
114-
end
115-
116102
@doc """
117103
report an account
118104
"""
@@ -190,7 +176,7 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
190176
with {:ok, comment} <- ORM.find(ArticleComment, comment_id) do
191177
Multi.new()
192178
|> Multi.run(:create_abuse_report, fn _, _ ->
193-
CMS.create_report(:article_comment, comment_id, reason, attr, user)
179+
create_report(:article_comment, comment_id, reason, attr, user)
194180
end)
195181
|> Multi.run(:update_report_meta, fn _, _ ->
196182
{:ok, info} = match(:article_comment)
@@ -210,7 +196,21 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
210196
undo_report_article(:article_comment, comment_id, user)
211197
end
212198

213-
def create_report(type, content_id, reason, attr, %User{} = user) do
199+
defp do_list_reports(query, thread, filter) do
200+
%{page: page, size: size} = filter
201+
202+
query
203+
|> QueryBuilder.filter_pack(filter)
204+
|> ORM.paginater(~m(page size)a)
205+
|> reports_formater(thread)
206+
|> done()
207+
end
208+
209+
defp do_list_reports(query, %{page: page, size: size}) do
210+
query |> ORM.paginater(~m(page size)a) |> done()
211+
end
212+
213+
defp create_report(type, content_id, reason, attr, %User{} = user) do
214214
with {:ok, info} <- match(type),
215215
{:ok, report} <- not_reported_before(info, content_id, user) do
216216
case report do

0 commit comments

Comments
 (0)