mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
import helper instead of calling plug directly
This commit is contained in:
parent
c776a29094
commit
9f4b8c3556
32 changed files with 54 additions and 63 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}} ->
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}"
|
||||
)
|
||||
|
|
|
@ -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}"
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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} ->
|
||||
|
|
|
@ -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} ->
|
||||
|
|
|
@ -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} ->
|
||||
|
|
|
@ -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) <>
|
||||
|
|
|
@ -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) <>
|
||||
|
|
|
@ -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} ->
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue