mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
dupe logs
This commit is contained in:
parent
9f4b8c3556
commit
57eab20972
4 changed files with 43 additions and 5 deletions
|
@ -17,9 +17,10 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
case DuplicateReports.accept_duplicate_report(report, user) do
|
case DuplicateReports.accept_duplicate_report(report, user) do
|
||||||
{:ok, _report} ->
|
{:ok, report} ->
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Successfully accepted report.")
|
|> put_flash(:info, "Successfully accepted report.")
|
||||||
|
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
|
|
||||||
_error ->
|
_error ->
|
||||||
|
@ -28,4 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp log_details(conn, _action, report) do
|
||||||
|
%{
|
||||||
|
body: "Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||||
|
subject_path: Routes.image_path(conn, :show, report.image)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,9 +17,10 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
case DuplicateReports.accept_reverse_duplicate_report(report, user) do
|
case DuplicateReports.accept_reverse_duplicate_report(report, user) do
|
||||||
{:ok, _report} ->
|
{:ok, report} ->
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Successfully accepted report in reverse.")
|
|> put_flash(:info, "Successfully accepted report in reverse.")
|
||||||
|
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
|
|
||||||
_error ->
|
_error ->
|
||||||
|
@ -28,4 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp log_details(conn, _action, report) do
|
||||||
|
%{
|
||||||
|
body: "Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||||
|
subject_path: Routes.image_path(conn, :show, report.image)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
||||||
persisted: true
|
persisted: true
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
{:ok, _report} =
|
{:ok, report} =
|
||||||
DuplicateReports.claim_duplicate_report(
|
DuplicateReports.claim_duplicate_report(
|
||||||
conn.assigns.duplicate_report,
|
conn.assigns.duplicate_report,
|
||||||
conn.assigns.current_user
|
conn.assigns.current_user
|
||||||
|
@ -20,14 +20,28 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Successfully claimed report.")
|
|> put_flash(:info, "Successfully claimed report.")
|
||||||
|
|> moderation_log(details: &log_details/3, data: report)
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(conn, _params) do
|
def delete(conn, _params) do
|
||||||
{:ok, _report} = DuplicateReports.unclaim_duplicate_report(conn.assigns.duplicate_report)
|
{:ok, report} = DuplicateReports.unclaim_duplicate_report(conn.assigns.duplicate_report)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Successfully released report.")
|
|> put_flash(:info, "Successfully released report.")
|
||||||
|
|> moderation_log(details: &log_details/3)
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp log_details(conn, action, _) do
|
||||||
|
body = case action do
|
||||||
|
:create -> "Claimed a duplicate report"
|
||||||
|
:delete -> "Released a duplicate report"
|
||||||
|
end
|
||||||
|
|
||||||
|
%{
|
||||||
|
body: body,
|
||||||
|
subject_path: Routes.duplicate_report_path(conn, :index)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do
|
||||||
preload: [:image, :duplicate_of_image]
|
preload: [:image, :duplicate_of_image]
|
||||||
|
|
||||||
def create(conn, _params) do
|
def create(conn, _params) do
|
||||||
{:ok, _report} =
|
{:ok, report} =
|
||||||
DuplicateReports.reject_duplicate_report(
|
DuplicateReports.reject_duplicate_report(
|
||||||
conn.assigns.duplicate_report,
|
conn.assigns.duplicate_report,
|
||||||
conn.assigns.current_user
|
conn.assigns.current_user
|
||||||
|
@ -21,6 +21,14 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Successfully rejected report.")
|
|> put_flash(:info, "Successfully rejected report.")
|
||||||
|
|> moderation_log(details: &log_details/3, data: report)
|
||||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp log_details(conn, _action, report) do
|
||||||
|
%{
|
||||||
|
body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})",
|
||||||
|
subject_path: Routes.duplicate_report_path(conn, :index)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue