mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Merge pull request #306 from philomena-dev/moderation-log-cleanup
Moderation log cleanup
This commit is contained in:
commit
fb24d09760
41 changed files with 108 additions and 107 deletions
|
@ -18,11 +18,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist successfully marked as contacted.")
|
||||
|> moderation_log(details: &log_details/3, data: artist_link)
|
||||
|> moderation_log(details: &log_details/2, data: artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Contacted artist #{artist_link.user.name} at #{artist_link.uri}",
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
|
|
|
@ -17,11 +17,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist link successfully marked as rejected.")
|
||||
|> moderation_log(details: &log_details/3, data: artist_link)
|
||||
|> moderation_log(details: &log_details/2, data: artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Rejected artist link #{artist_link.uri} created by #{artist_link.user.name}",
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
|
|
|
@ -18,11 +18,11 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist link successfully verified.")
|
||||
|> moderation_log(details: &log_details/3, data: result.artist_link)
|
||||
|> moderation_log(details: &log_details/2, data: result.artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Verified artist link #{artist_link.uri} created by #{artist_link.user.name}",
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
|
|
|
@ -48,10 +48,11 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
|||
{:ok, _} ->
|
||||
conn
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
details: &log_details/2,
|
||||
data: %{
|
||||
tag_list: tag_list,
|
||||
image_count: Enum.count(image_ids)
|
||||
image_count: Enum.count(image_ids),
|
||||
user: conn.assigns.current_user
|
||||
}
|
||||
)
|
||||
|> json(%{succeeded: image_ids, failed: []})
|
||||
|
@ -68,10 +69,10 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, data) do
|
||||
defp log_details(_action, data) do
|
||||
%{
|
||||
body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images",
|
||||
subject_path: ~p"/profiles/#{conn.assigns.current_user}"
|
||||
subject_path: ~p"/profiles/#{data.user}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
{:ok, fingerprint_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -70,7 +70,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
{:ok, fingerprint_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -83,7 +83,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
end
|
||||
|
||||
|
@ -115,7 +115,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a fingerprint ban #{ban.generated_ban_id}"
|
||||
|
|
|
@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
{:ok, subnet_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Subnet was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -67,7 +67,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
{:ok, subnet_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Subnet ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -80,7 +80,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Subnet ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
end
|
||||
|
||||
|
@ -112,7 +112,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a subnet ban #{ban.generated_ban_id}"
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User verification granted.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User verification revoked.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, user) do
|
||||
defp log_details(action, user) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Granted verification to #{user.name}"
|
||||
|
|
|
@ -50,7 +50,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
{:ok, user_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "User was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
|
||||
{:error, :user_ban, changeset, _changes} ->
|
||||
|
@ -71,7 +71,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
{:ok, user_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "User ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -84,7 +84,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
end
|
||||
|
||||
|
@ -116,7 +116,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a user ban #{ban.generated_ban_id}"
|
||||
|
|
|
@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "User successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -81,7 +81,7 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
assign(conn, :roles, Repo.all(Role))
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, user) do
|
||||
defp log_details(_action, user) do
|
||||
%{
|
||||
body: "Updated user details for #{user.name}",
|
||||
subject_path: ~p"/profiles/#{user}"
|
||||
|
|
|
@ -20,11 +20,11 @@ defmodule PhilomenaWeb.Conversation.Message.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation message approved.")
|
||||
|> moderation_log(details: &log_details/3, data: message)
|
||||
|> moderation_log(details: &log_details/2, data: message)
|
||||
|> redirect(to: "/")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, message) do
|
||||
defp log_details(_action, message) do
|
||||
%{
|
||||
body: "Approved private message in conversation ##{message.conversation_id}",
|
||||
subject_path: "/"
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
|
|||
{:ok, report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully accepted report.")
|
||||
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||
|> moderation_log(details: &log_details/2, data: report.duplicate_report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
|
||||
_error ->
|
||||
|
@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body:
|
||||
"Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
|
|||
{:ok, report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully accepted report in reverse.")
|
||||
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||
|> moderation_log(details: &log_details/2, data: report.duplicate_report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
|
||||
_error ->
|
||||
|
@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body:
|
||||
"Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully claimed report.")
|
||||
|> moderation_log(details: &log_details/3, data: report)
|
||||
|> moderation_log(details: &log_details/2, data: report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
|
@ -29,11 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully released report.")
|
||||
|> moderation_log(details: &log_details/3)
|
||||
|> moderation_log(details: &log_details/2)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, _) do
|
||||
defp log_details(action, _) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Claimed a duplicate report"
|
||||
|
|
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully rejected report.")
|
||||
|> moderation_log(details: &log_details/3, data: report)
|
||||
|> moderation_log(details: &log_details/2, data: report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})",
|
||||
subject_path: ~p"/duplicate_reports"
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated anonymity.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Updated anonymity of image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image has been approved.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/admin/approvals")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,11 +22,11 @@ defmodule PhilomenaWeb.Image.Comment.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Comment has been approved.")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, comment) do
|
||||
defp log_details(_action, comment) do
|
||||
%{
|
||||
body: "Approved comment on image >>#{comment.image_id}",
|
||||
subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}"
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully destroyed!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, comment) do
|
||||
defp log_details(_action, comment) do
|
||||
%{
|
||||
body: "Destroyed comment on image >>#{comment.image_id}",
|
||||
subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}"
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
{:ok, comment} ->
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully hidden!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
_error ->
|
||||
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
{:ok, comment} ->
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully unhidden!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, comment) do
|
||||
defp log_details(action, comment) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Hidden comment on image >>#{comment.image_id} (#{comment.deletion_reason})"
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked comments.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked comments.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked comments on image >>#{image.id}"
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
{:ok, result} ->
|
||||
conn
|
||||
|> put_flash(:info, "Image successfully hidden.")
|
||||
|> moderation_log(details: &log_details/3, data: result.image)
|
||||
|> moderation_log(details: &log_details/2, data: result.image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
_error ->
|
||||
|
@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
{:ok, image} ->
|
||||
conn
|
||||
|> put_flash(:info, "Hide reason updated.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -66,11 +66,11 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image successfully unhidden.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Hidden image >>#{image.id} (#{image.deletion_reason})"
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked description.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked description.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked description editing on image >>#{image.id}"
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.DestroyController do
|
|||
{:ok, image} ->
|
||||
conn
|
||||
|> put_flash(:info, "Image contents destroyed.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
_error ->
|
||||
|
@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Image.DestroyController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Hard-deleted image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.FeatureController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image marked as featured image.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.FeatureController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Featured image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -12,11 +12,11 @@ defmodule PhilomenaWeb.Image.HashController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully cleared hash.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Cleared hash of image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -13,11 +13,11 @@ defmodule PhilomenaWeb.Image.RepairController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Repair job enqueued.")
|
||||
|> moderation_log(details: &log_details/3, data: conn.assigns.image)
|
||||
|> moderation_log(details: &log_details/2, data: conn.assigns.image)
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Repaired image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -17,11 +17,11 @@ defmodule PhilomenaWeb.Image.ScratchpadController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated moderation notes.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Updated mod notes on image >>#{image.id} (#{image.scratchpad})",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully deleted source history.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Deleted source history for image >>#{image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
conn
|
||||
|> put_flash(:info, "Successfully deleted tag change from history.")
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
details: &log_details/2,
|
||||
data: %{image: image, details: tag_change_details(tag_change)}
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
@ -58,7 +58,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
defp added_filter(query, _params),
|
||||
do: query
|
||||
|
||||
defp log_details(_conn, _action, %{image: image, details: details}) do
|
||||
defp log_details(_action, %{image: image, details: details}) do
|
||||
%{
|
||||
body: "Deleted tag change #{details} on >>#{image.id} from history",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated list of locked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
|
@ -41,11 +41,11 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked tags on image >>#{image.id}"
|
||||
|
|
|
@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Image.TamperController do
|
|||
conn
|
||||
|> put_flash(:info, "Vote removed.")
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
data: %{vote: result, image: image}
|
||||
details: &log_details/2,
|
||||
data: %{vote: result, image: image, username: conn.assigns.user.name}
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, data) do
|
||||
defp log_details(_action, data) do
|
||||
image = data.image
|
||||
|
||||
vote_type =
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.TamperController do
|
|||
end
|
||||
|
||||
%{
|
||||
body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.image.id}",
|
||||
body: "Deleted #{vote_type} by #{data.username} on image >>#{data.image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
{:ok, tag} ->
|
||||
conn
|
||||
|> put_flash(:info, "Tag image successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
|
||||
{:error, :tag, changeset, _changes} ->
|
||||
|
@ -36,11 +36,11 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag image successfully removed.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{conn.assigns.tag}")
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, tag) do
|
||||
defp log_details(action, tag) do
|
||||
body =
|
||||
case action do
|
||||
:update -> "Updated image on tag '#{tag.name}'"
|
||||
|
|
|
@ -97,7 +97,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
{:ok, tag} ->
|
||||
conn
|
||||
|> put_flash(:info, "Tag successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
|
||||
{:error, changeset} ->
|
||||
|
@ -110,7 +110,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag queued for deletion.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: "/")
|
||||
end
|
||||
|
||||
|
@ -172,7 +172,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, tag) do
|
||||
defp log_details(action, tag) do
|
||||
body =
|
||||
case action do
|
||||
:update -> "Updated details on tag '#{tag.name}'"
|
||||
|
|
|
@ -27,7 +27,7 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully hidden!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -44,7 +44,7 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully restored!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, topic) do
|
||||
defp log_details(action, topic) do
|
||||
body =
|
||||
case action do
|
||||
:create ->
|
||||
|
|
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully locked!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully unlocked!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -53,7 +53,7 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, topic) do
|
||||
defp log_details(action, topic) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked topic '#{topic.title}' (#{topic.lock_reason}) in #{topic.forum.name}"
|
||||
|
|
|
@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Topic.MoveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully moved!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Topic.MoveController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, topic) do
|
||||
defp log_details(_action, topic) do
|
||||
%{
|
||||
body: "Topic '#{topic.title}' moved to #{topic.forum.name}",
|
||||
subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}"
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do
|
|||
{:ok, post} ->
|
||||
conn
|
||||
|> put_flash(:info, "Post successfully approved.")
|
||||
|> moderation_log(details: &log_details/3, data: post)
|
||||
|> moderation_log(details: &log_details/2, data: post)
|
||||
|> redirect(
|
||||
to:
|
||||
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
|
||||
|
@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, post) do
|
||||
defp log_details(_action, post) do
|
||||
%{
|
||||
body: "Approved forum post ##{post.id} in topic '#{post.topic.title}'",
|
||||
subject_path:
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do
|
|||
{:ok, post} ->
|
||||
conn
|
||||
|> put_flash(:info, "Post successfully destroyed!")
|
||||
|> moderation_log(details: &log_details/3, data: post)
|
||||
|> moderation_log(details: &log_details/2, data: post)
|
||||
|> redirect(
|
||||
to:
|
||||
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
|
||||
|
@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, post) do
|
||||
defp log_details(_action, post) do
|
||||
%{
|
||||
body: "Destroyed forum post ##{post.id} in topic '#{post.topic.title}'",
|
||||
subject_path:
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do
|
|||
{:ok, post} ->
|
||||
conn
|
||||
|> put_flash(:info, "Post successfully hidden.")
|
||||
|> moderation_log(details: &log_details/3, data: post)
|
||||
|> moderation_log(details: &log_details/2, data: post)
|
||||
|> redirect(
|
||||
to:
|
||||
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
|
||||
|
@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do
|
|||
{:ok, post} ->
|
||||
conn
|
||||
|> put_flash(:info, "Post successfully unhidden.")
|
||||
|> moderation_log(details: &log_details/3, data: post)
|
||||
|> moderation_log(details: &log_details/2, data: post)
|
||||
|> redirect(
|
||||
to:
|
||||
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
|
||||
|
@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, post) do
|
||||
defp log_details(action, post) do
|
||||
body =
|
||||
case action do
|
||||
:create ->
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Topic.StickController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully stickied!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Topic.StickController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully unstickied!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
|
@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Topic.StickController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(_conn, action, topic) do
|
||||
defp log_details(action, topic) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Stickied topic '#{topic.title}' in #{topic.forum.name}"
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.ModerationLogPlug do
|
|||
def init(opts), do: opts
|
||||
|
||||
@type log_details :: %{subject_path: String.t(), body: String.t()}
|
||||
@type details_func :: (Plug.Conn.t(), atom(), any() -> log_details())
|
||||
@type details_func :: (atom(), any() -> log_details())
|
||||
@type call_opts :: [details: details_func, data: any()]
|
||||
|
||||
@doc false
|
||||
|
@ -29,7 +29,7 @@ defmodule PhilomenaWeb.ModerationLogPlug do
|
|||
user = conn.assigns.current_user
|
||||
action = Controller.action_name(conn)
|
||||
|
||||
%{subject_path: subject_path, body: body} = details_func.(conn, action, userdata)
|
||||
%{subject_path: subject_path, body: body} = details_func.(action, userdata)
|
||||
|
||||
mod = Controller.controller_module(conn)
|
||||
[mod_name] = Regex.run(@controller_regex, to_string(mod), capture: :all_but_first)
|
||||
|
|
Loading…
Reference in a new issue