mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
Document create_system_report and flip argument order
This commit is contained in:
parent
0601625f27
commit
c9bcda4e0a
5 changed files with 16 additions and 6 deletions
|
@ -210,8 +210,8 @@ defmodule Philomena.Comments do
|
||||||
|
|
||||||
def report_non_approved(comment) do
|
def report_non_approved(comment) do
|
||||||
Reports.create_system_report(
|
Reports.create_system_report(
|
||||||
comment.id,
|
|
||||||
"Comment",
|
"Comment",
|
||||||
|
comment.id,
|
||||||
"Approval",
|
"Approval",
|
||||||
"Comment contains externally-embedded images and has been flagged for review."
|
"Comment contains externally-embedded images and has been flagged for review."
|
||||||
)
|
)
|
||||||
|
|
|
@ -236,8 +236,8 @@ defmodule Philomena.Conversations do
|
||||||
|
|
||||||
def report_non_approved(id) do
|
def report_non_approved(id) do
|
||||||
Reports.create_system_report(
|
Reports.create_system_report(
|
||||||
id,
|
|
||||||
"Conversation",
|
"Conversation",
|
||||||
|
id,
|
||||||
"Approval",
|
"Approval",
|
||||||
"PM contains externally-embedded images and has been flagged for review."
|
"PM contains externally-embedded images and has been flagged for review."
|
||||||
)
|
)
|
||||||
|
|
|
@ -193,8 +193,8 @@ defmodule Philomena.Images do
|
||||||
|
|
||||||
defp maybe_suggest_user_verification(%User{id: id, uploads_count: 5, verified: false}) do
|
defp maybe_suggest_user_verification(%User{id: id, uploads_count: 5, verified: false}) do
|
||||||
Reports.create_system_report(
|
Reports.create_system_report(
|
||||||
id,
|
|
||||||
"User",
|
"User",
|
||||||
|
id,
|
||||||
"Verification",
|
"Verification",
|
||||||
"User has uploaded enough approved images to be considered for verification."
|
"User has uploaded enough approved images to be considered for verification."
|
||||||
)
|
)
|
||||||
|
|
|
@ -114,8 +114,8 @@ defmodule Philomena.Posts do
|
||||||
|
|
||||||
def report_non_approved(post) do
|
def report_non_approved(post) do
|
||||||
Reports.create_system_report(
|
Reports.create_system_report(
|
||||||
post.id,
|
|
||||||
"Post",
|
"Post",
|
||||||
|
post.id,
|
||||||
"Approval",
|
"Approval",
|
||||||
"Post contains externally-embedded images and has been flagged for review."
|
"Post contains externally-embedded images and has been flagged for review."
|
||||||
)
|
)
|
||||||
|
|
|
@ -95,7 +95,17 @@ defmodule Philomena.Reports do
|
||||||
update: [set: [open: false, state: "closed", admin_id: ^closing_user.id]]
|
update: [set: [open: false, state: "closed", admin_id: ^closing_user.id]]
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_system_report(reportable_id, reportable_type, category, reason) do
|
@doc """
|
||||||
|
Automatically create a report with the given category and reason on the given
|
||||||
|
`reportable_id` and `reportable_type`.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_system_report("Comment", 1, "Other", "Custom report reason")
|
||||||
|
{:ok, %Report{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_system_report(reportable_type, reportable_id, category, reason) do
|
||||||
attrs = %{
|
attrs = %{
|
||||||
reason: reason,
|
reason: reason,
|
||||||
category: category
|
category: category
|
||||||
|
@ -109,7 +119,7 @@ defmodule Philomena.Reports do
|
||||||
"Mozilla/5.0 (X11; Philomena; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
|
"Mozilla/5.0 (X11; Philomena; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
%Report{reportable_id: reportable_id, reportable_type: reportable_type}
|
%Report{reportable_type: reportable_type, reportable_id: reportable_id}
|
||||||
|> Report.creation_changeset(attrs, attributes)
|
|> Report.creation_changeset(attrs, attributes)
|
||||||
|> Repo.insert()
|
|> Repo.insert()
|
||||||
|> reindex_after_update()
|
|> reindex_after_update()
|
||||||
|
|
Loading…
Reference in a new issue