mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27:59 +01:00
dfeefb1651
git grep -l 'defp log_details(_conn' | xargs sed -i -e 's/defp log_details(_conn, /defp log_details(/g' git grep -l '&log_details/3' | xargs sed -i -e 's|\&log_details/3|\&log_details/2|g'
33 lines
866 B
Elixir
33 lines
866 B
Elixir
defmodule PhilomenaWeb.Conversation.Message.ApproveController do
|
|
use PhilomenaWeb, :controller
|
|
|
|
alias Philomena.Conversations.Message
|
|
alias Philomena.Conversations
|
|
|
|
plug PhilomenaWeb.CanaryMapPlug, create: :approve
|
|
|
|
plug :load_and_authorize_resource,
|
|
model: Message,
|
|
id_name: "message_id",
|
|
persisted: true,
|
|
preload: [:conversation]
|
|
|
|
def create(conn, _params) do
|
|
message = conn.assigns.message
|
|
|
|
{:ok, _message} =
|
|
Conversations.approve_conversation_message(message, conn.assigns.current_user)
|
|
|
|
conn
|
|
|> put_flash(:info, "Conversation message approved.")
|
|
|> moderation_log(details: &log_details/2, data: message)
|
|
|> redirect(to: "/")
|
|
end
|
|
|
|
defp log_details(_action, message) do
|
|
%{
|
|
body: "Approved private message in conversation ##{message.conversation_id}",
|
|
subject_path: "/"
|
|
}
|
|
end
|
|
end
|