mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
add reporting to conversations
This commit is contained in:
parent
2bc39e8416
commit
c3d6a3817e
4 changed files with 36 additions and 2 deletions
|
@ -0,0 +1,34 @@
|
|||
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 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", 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
|
|
@ -91,6 +91,7 @@ defmodule PhilomenaWeb.Router do
|
|||
end
|
||||
resources "/notifications", NotificationController, only: [:index, :delete]
|
||||
resources "/conversations", ConversationController, only: [:index, :show, :new, :create] do
|
||||
resources "/reports", Conversation.ReportController, only: [:new, :create]
|
||||
resources "/messages", Conversation.MessageController, only: [:create]
|
||||
end
|
||||
resources "/images", ImageController, only: [] do
|
||||
|
|
|
@ -13,6 +13,7 @@ h1 = @conversation.title
|
|||
=> render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other}, conn: @conn
|
||||
.block__header--sub.block__header--light
|
||||
= pagination
|
||||
= link "Report conversation", to: Routes.conversation_report_path(@conn, :new, @conversation)
|
||||
|
||||
= for {message, body} <- @messages do
|
||||
= render PhilomenaWeb.MessageView, "_message.html", message: message, body: body, conn: @conn
|
||||
|
|
|
@ -10,8 +10,6 @@ article.block.communication
|
|||
|
||||
= render PhilomenaWeb.UserAttributionView, "_user_title.html", object: %{user: @message.from}, conn: @conn
|
||||
|
||||
br
|
||||
|
||||
.communication__body__text
|
||||
== @body
|
||||
|
||||
|
|
Loading…
Reference in a new issue