mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 23:08:00 +01:00
47 lines
1.3 KiB
Elixir
47 lines
1.3 KiB
Elixir
defmodule PhilomenaWeb.Conversation.ReportController do
|
|
use PhilomenaWeb, :controller
|
|
|
|
alias PhilomenaWeb.ReportController
|
|
alias PhilomenaWeb.ReportView
|
|
alias Philomena.Conversations.Conversation
|
|
alias Philomena.Reports.Report
|
|
alias Philomena.Reports
|
|
|
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
|
plug PhilomenaWeb.UserAttributionPlug
|
|
plug PhilomenaWeb.CaptchaPlug
|
|
plug PhilomenaWeb.CheckCaptchaPlug when action in [:create]
|
|
plug PhilomenaWeb.CanaryMapPlug, new: :show, create: :show
|
|
|
|
plug :load_and_authorize_resource,
|
|
model: Conversation,
|
|
id_name: "conversation_id",
|
|
id_field: "slug",
|
|
persisted: true,
|
|
preload: [:from, :to]
|
|
|
|
def new(conn, _params) do
|
|
conversation = conn.assigns.conversation
|
|
action = Routes.conversation_report_path(conn, :create, conversation)
|
|
|
|
changeset =
|
|
%Report{reportable_type: "Conversation", reportable_id: conversation.id}
|
|
|> Reports.change_report()
|
|
|
|
conn
|
|
|> put_view(ReportView)
|
|
|> render("new.html",
|
|
title: "Reporting Conversation",
|
|
reportable: conversation,
|
|
changeset: changeset,
|
|
action: action
|
|
)
|
|
end
|
|
|
|
def create(conn, params) do
|
|
conversation = conn.assigns.conversation
|
|
action = Routes.conversation_report_path(conn, :create, conversation)
|
|
|
|
ReportController.create(conn, action, conversation, "Conversation", params)
|
|
end
|
|
end
|