diff --git a/lib/philomena_web.ex b/lib/philomena_web.ex index 2fcddf06..52e299ab 100644 --- a/lib/philomena_web.ex +++ b/lib/philomena_web.ex @@ -24,6 +24,7 @@ defmodule PhilomenaWeb do import Plug.Conn import PhilomenaWeb.Gettext import Canary.Plugs + import PhilomenaWeb.ModerationLogPlug, only: [moderation_log: 2] alias PhilomenaWeb.Router.Helpers, as: Routes end end diff --git a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex index ab2bfa4f..98efb1f4 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do conn |> put_flash(:info, "Artist successfully marked as contacted.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: artist_link) + |> moderation_log(details: &log_details/3, data: artist_link) |> redirect(to: Routes.admin_artist_link_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex index 6337f0e9..9bf92139 100644 --- a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do conn |> put_flash(:info, "Artist link successfully marked as rejected.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: artist_link) + |> moderation_log(details: &log_details/3, data: artist_link) |> redirect(to: Routes.admin_artist_link_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex index 1f683542..a4cc1fce 100644 --- a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do conn |> put_flash(:info, "Artist link successfully verified.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: result.artist_link) + |> moderation_log(details: &log_details/3, data: result.artist_link) |> redirect(to: Routes.admin_artist_link_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 0b4eecc1..4ae3c714 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -47,7 +47,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do case Images.batch_update(image_ids, added_tags, removed_tags, attributes) do {:ok, _} -> conn - |> PhilomenaWeb.ModerationLogPlug.call( + |> moderation_log( details: &log_details/3, data: %{ tag_list: tag_list, diff --git a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex index 0cd9a7b7..5cb4ccd0 100644 --- a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Bans.Fingerprint, as: FingerprintBan alias Philomena.Bans alias Philomena.Repo @@ -48,7 +47,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint was successfully banned.") - |> ModerationLogPlug.call(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/3, data: fingerprint_ban) |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) {:error, changeset} -> @@ -66,7 +65,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint ban successfully updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/3, data: fingerprint_ban) |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) {:error, changeset} -> @@ -79,7 +78,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do conn |> put_flash(:info, "Fingerprint ban successfully deleted.") - |> ModerationLogPlug.call(details: &log_details/3, data: fingerprint_ban) + |> moderation_log(details: &log_details/3, data: fingerprint_ban) |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex index 45d500e7..93c42807 100644 --- a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Bans.Subnet, as: SubnetBan alias Philomena.Bans alias Philomena.Repo @@ -50,7 +49,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet was successfully banned.") - |> ModerationLogPlug.call(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/3, data: subnet_ban) |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) {:error, changeset} -> @@ -68,7 +67,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet ban successfully updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/3, data: subnet_ban) |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) {:error, changeset} -> @@ -81,7 +80,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do conn |> put_flash(:info, "Subnet ban successfully deleted.") - |> ModerationLogPlug.call(details: &log_details/3, data: subnet_ban) + |> moderation_log(details: &log_details/3, data: subnet_ban) |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/user_ban_controller.ex b/lib/philomena_web/controllers/admin/user_ban_controller.ex index e2b07459..f98c3337 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Admin.UserBanController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Bans.User, as: UserBan alias Philomena.Bans alias Philomena.Repo @@ -51,7 +50,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User was successfully banned.") - |> ModerationLogPlug.call(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/3, data: user_ban) |> redirect(to: Routes.admin_user_ban_path(conn, :index)) {:error, :user_ban, changeset, _changes} -> @@ -72,7 +71,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User ban successfully updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/3, data: user_ban) |> redirect(to: Routes.admin_user_ban_path(conn, :index)) {:error, changeset} -> @@ -85,7 +84,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do conn |> put_flash(:info, "User ban successfully deleted.") - |> ModerationLogPlug.call(details: &log_details/3, data: user_ban) + |> moderation_log(details: &log_details/3, data: user_ban) |> redirect(to: Routes.admin_user_ban_path(conn, :index)) end diff --git a/lib/philomena_web/controllers/admin/user_controller.ex b/lib/philomena_web/controllers/admin/user_controller.ex index 296e3d30..19b1616d 100644 --- a/lib/philomena_web/controllers/admin/user_controller.ex +++ b/lib/philomena_web/controllers/admin/user_controller.ex @@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Admin.UserController do {:ok, user} -> conn |> put_flash(:info, "User successfully updated.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: user) + |> moderation_log(details: &log_details/3, data: user) |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) {:error, %{user: changeset}} -> diff --git a/lib/philomena_web/controllers/image/anonymous_controller.ex b/lib/philomena_web/controllers/image/anonymous_controller.ex index e8c5de7e..d74b1682 100644 --- a/lib/philomena_web/controllers/image/anonymous_controller.ex +++ b/lib/philomena_web/controllers/image/anonymous_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do conn |> put_flash(:info, "Successfully updated anonymity.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/comment/delete_controller.ex b/lib/philomena_web/controllers/image/comment/delete_controller.ex index ab74a883..4527e759 100644 --- a/lib/philomena_web/controllers/image/comment/delete_controller.ex +++ b/lib/philomena_web/controllers/image/comment/delete_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do conn |> put_flash(:info, "Comment successfully destroyed!") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/3, data: comment) |> redirect( to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" ) diff --git a/lib/philomena_web/controllers/image/comment/hide_controller.ex b/lib/philomena_web/controllers/image/comment/hide_controller.ex index a8c8cd64..1e55f86d 100644 --- a/lib/philomena_web/controllers/image/comment/hide_controller.ex +++ b/lib/philomena_web/controllers/image/comment/hide_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Image.Comment.HideController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Comments.Comment alias Philomena.Comments @@ -16,7 +15,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully hidden!") - |> ModerationLogPlug.call(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/3, data: comment) |> redirect( to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" ) @@ -37,7 +36,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully unhidden!") - |> ModerationLogPlug.call(details: &log_details/3, data: comment) + |> moderation_log(details: &log_details/3, data: comment) |> redirect( to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" ) diff --git a/lib/philomena_web/controllers/image/comment_lock_controller.ex b/lib/philomena_web/controllers/image/comment_lock_controller.ex index a443fca5..e913bdb6 100644 --- a/lib/philomena_web/controllers/image/comment_lock_controller.ex +++ b/lib/philomena_web/controllers/image/comment_lock_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Image.CommentLockController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Images.Image alias Philomena.Images @@ -13,7 +12,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully locked comments.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end @@ -22,7 +21,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully unlocked comments.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/delete_controller.ex b/lib/philomena_web/controllers/image/delete_controller.ex index 50f22292..adae818c 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -4,7 +4,6 @@ defmodule PhilomenaWeb.Image.DeleteController do # N.B.: this would be Image.Hide, because it hides the image, but that is # taken by the user action - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Images.Image alias Philomena.Images @@ -20,7 +19,7 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, result} -> conn |> put_flash(:info, "Image successfully hidden.") - |> ModerationLogPlug.call(details: &log_details/3, data: result.image) + |> moderation_log(details: &log_details/3, data: result.image) |> redirect(to: Routes.image_path(conn, :show, image)) _error -> @@ -37,7 +36,7 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, image} -> conn |> put_flash(:info, "Hide reason updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) {:error, _changeset} -> @@ -67,7 +66,7 @@ defmodule PhilomenaWeb.Image.DeleteController do conn |> put_flash(:info, "Image successfully unhidden.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/description_lock_controller.ex b/lib/philomena_web/controllers/image/description_lock_controller.ex index 83c0c427..ed8c9c87 100644 --- a/lib/philomena_web/controllers/image/description_lock_controller.ex +++ b/lib/philomena_web/controllers/image/description_lock_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Images.Image alias Philomena.Images @@ -13,7 +12,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully locked description.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end @@ -22,7 +21,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully unlocked description.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/destroy_controller.ex b/lib/philomena_web/controllers/image/destroy_controller.ex index 38f526e5..fe2f3e6e 100644 --- a/lib/philomena_web/controllers/image/destroy_controller.ex +++ b/lib/philomena_web/controllers/image/destroy_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.DestroyController do {:ok, image} -> conn |> put_flash(:info, "Image contents destroyed.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) _error -> diff --git a/lib/philomena_web/controllers/image/feature_controller.ex b/lib/philomena_web/controllers/image/feature_controller.ex index 1648cffc..a16ee809 100644 --- a/lib/philomena_web/controllers/image/feature_controller.ex +++ b/lib/philomena_web/controllers/image/feature_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.FeatureController do conn |> put_flash(:info, "Image marked as featured image.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/hash_controller.ex b/lib/philomena_web/controllers/image/hash_controller.ex index 552ad521..ad99b133 100644 --- a/lib/philomena_web/controllers/image/hash_controller.ex +++ b/lib/philomena_web/controllers/image/hash_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.HashController do conn |> put_flash(:info, "Successfully cleared hash.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/repair_controller.ex b/lib/philomena_web/controllers/image/repair_controller.ex index dc463849..7e40835a 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -13,7 +13,7 @@ defmodule PhilomenaWeb.Image.RepairController do conn |> put_flash(:info, "Repair job enqueued.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: conn.assigns.image) + |> moderation_log(details: &log_details/3, data: conn.assigns.image) |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) end diff --git a/lib/philomena_web/controllers/image/scratchpad_controller.ex b/lib/philomena_web/controllers/image/scratchpad_controller.ex index 28c2bd54..863c0bc8 100644 --- a/lib/philomena_web/controllers/image/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/image/scratchpad_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Image.ScratchpadController do conn |> put_flash(:info, "Successfully updated moderation notes.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/source_history_controller.ex b/lib/philomena_web/controllers/image/source_history_controller.ex index 9d3ffe52..24bab27f 100644 --- a/lib/philomena_web/controllers/image/source_history_controller.ex +++ b/lib/philomena_web/controllers/image/source_history_controller.ex @@ -14,7 +14,7 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do conn |> put_flash(:info, "Successfully deleted source history.") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/tag_lock_controller.ex b/lib/philomena_web/controllers/image/tag_lock_controller.ex index b32b020d..2f71b4a3 100644 --- a/lib/philomena_web/controllers/image/tag_lock_controller.ex +++ b/lib/philomena_web/controllers/image/tag_lock_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Image.TagLockController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Images.Image alias Philomena.Images @@ -24,7 +23,7 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully updated list of locked tags.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end @@ -33,7 +32,7 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully locked tags.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end @@ -42,7 +41,7 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully unlocked tags.") - |> ModerationLogPlug.call(details: &log_details/3, data: image) + |> moderation_log(details: &log_details/3, data: image) |> redirect(to: Routes.image_path(conn, :show, image)) end diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 8b01eb40..8eb66309 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Image.TamperController do conn |> put_flash(:info, "Vote removed.") - |> PhilomenaWeb.ModerationLogPlug.call( + |> moderation_log( details: &log_details/3, data: %{vote: result, image: image} ) diff --git a/lib/philomena_web/controllers/tag/image_controller.ex b/lib/philomena_web/controllers/tag/image_controller.ex index 9ac53dcb..2f43ebe8 100644 --- a/lib/philomena_web/controllers/tag/image_controller.ex +++ b/lib/philomena_web/controllers/tag/image_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Tag.ImageController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Tags.Tag alias Philomena.Tags @@ -24,7 +23,7 @@ defmodule PhilomenaWeb.Tag.ImageController do {:ok, tag} -> conn |> put_flash(:info, "Tag image successfully updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/3, data: tag) |> redirect(to: Routes.tag_path(conn, :show, tag)) {:error, :tag, changeset, _changes} -> @@ -37,7 +36,7 @@ defmodule PhilomenaWeb.Tag.ImageController do conn |> put_flash(:info, "Tag image successfully removed.") - |> ModerationLogPlug.call(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/3, data: tag) |> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag)) end diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 92ea1501..766508ae 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.TagController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias PhilomenaWeb.ImageLoader alias Philomena.Elasticsearch alias Philomena.{Tags, Tags.Tag} @@ -98,7 +97,7 @@ defmodule PhilomenaWeb.TagController do {:ok, tag} -> conn |> put_flash(:info, "Tag successfully updated.") - |> ModerationLogPlug.call(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/3, data: tag) |> redirect(to: Routes.tag_path(conn, :show, tag)) {:error, changeset} -> @@ -111,7 +110,7 @@ defmodule PhilomenaWeb.TagController do conn |> put_flash(:info, "Tag queued for deletion.") - |> ModerationLogPlug.call(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/3, data: tag) |> redirect(to: "/") end diff --git a/lib/philomena_web/controllers/topic/hide_controller.ex b/lib/philomena_web/controllers/topic/hide_controller.ex index 575da8cc..3149501d 100644 --- a/lib/philomena_web/controllers/topic/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/hide_controller.ex @@ -2,7 +2,6 @@ defmodule PhilomenaWeb.Topic.HideController do import Plug.Conn use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Forums.Forum alias Philomena.Topics.Topic alias Philomena.Topics @@ -28,7 +27,7 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully hidden!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> @@ -45,7 +44,7 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully restored!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> diff --git a/lib/philomena_web/controllers/topic/lock_controller.ex b/lib/philomena_web/controllers/topic/lock_controller.ex index 5936bd29..88bf115b 100644 --- a/lib/philomena_web/controllers/topic/lock_controller.ex +++ b/lib/philomena_web/controllers/topic/lock_controller.ex @@ -2,7 +2,6 @@ defmodule PhilomenaWeb.Topic.LockController do import Plug.Conn use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Forums.Forum alias Philomena.Topics.Topic alias Philomena.Topics @@ -27,7 +26,7 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully locked!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> @@ -44,7 +43,7 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unlocked!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> diff --git a/lib/philomena_web/controllers/topic/move_controller.ex b/lib/philomena_web/controllers/topic/move_controller.ex index fccb3134..f12af72e 100644 --- a/lib/philomena_web/controllers/topic/move_controller.ex +++ b/lib/philomena_web/controllers/topic/move_controller.ex @@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Topic.MoveController do conn |> put_flash(:info, "Topic successfully moved!") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> diff --git a/lib/philomena_web/controllers/topic/post/delete_controller.ex b/lib/philomena_web/controllers/topic/post/delete_controller.ex index 8fd7800a..9e6d7a45 100644 --- a/lib/philomena_web/controllers/topic/post/delete_controller.ex +++ b/lib/philomena_web/controllers/topic/post/delete_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do {:ok, post} -> conn |> put_flash(:info, "Post successfully destroyed!") - |> PhilomenaWeb.ModerationLogPlug.call(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/3, data: post) |> redirect( to: Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> diff --git a/lib/philomena_web/controllers/topic/post/hide_controller.ex b/lib/philomena_web/controllers/topic/post/hide_controller.ex index 6b40ccff..9e449977 100644 --- a/lib/philomena_web/controllers/topic/post/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/post/hide_controller.ex @@ -1,7 +1,6 @@ defmodule PhilomenaWeb.Topic.Post.HideController do use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Posts.Post alias Philomena.Posts @@ -21,7 +20,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully hidden.") - |> ModerationLogPlug.call(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/3, data: post) |> redirect( to: Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> @@ -46,7 +45,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully unhidden.") - |> ModerationLogPlug.call(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/3, data: post) |> redirect( to: Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> diff --git a/lib/philomena_web/controllers/topic/stick_controller.ex b/lib/philomena_web/controllers/topic/stick_controller.ex index b40dc937..27f92168 100644 --- a/lib/philomena_web/controllers/topic/stick_controller.ex +++ b/lib/philomena_web/controllers/topic/stick_controller.ex @@ -2,7 +2,6 @@ defmodule PhilomenaWeb.Topic.StickController do import Plug.Conn use PhilomenaWeb, :controller - alias PhilomenaWeb.ModerationLogPlug alias Philomena.Forums.Forum alias Philomena.Topics.Topic alias Philomena.Topics @@ -26,7 +25,7 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully stickied!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> @@ -43,7 +42,7 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unstickied!") - |> ModerationLogPlug.call(details: &log_details/3, data: topic) + |> moderation_log(details: &log_details/3, data: topic) |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) {:error, _changeset} -> diff --git a/lib/philomena_web/plugs/moderation_log_plug.ex b/lib/philomena_web/plugs/moderation_log_plug.ex index 40282748..4ee75938 100644 --- a/lib/philomena_web/plugs/moderation_log_plug.ex +++ b/lib/philomena_web/plugs/moderation_log_plug.ex @@ -39,4 +39,8 @@ defmodule PhilomenaWeb.ModerationLogPlug do conn end + + @doc false + @spec moderation_log(Conn.t(), call_opts()) :: Conn.t() + def moderation_log(conn, opts), do: call(conn, opts) end