mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
user reporting
This commit is contained in:
parent
c3d6a3817e
commit
3f6322ca81
3 changed files with 40 additions and 4 deletions
34
lib/philomena_web/controllers/profile/report_controller.ex
Normal file
34
lib/philomena_web/controllers/profile/report_controller.ex
Normal file
|
@ -0,0 +1,34 @@
|
|||
defmodule PhilomenaWeb.Profile.ReportController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias PhilomenaWeb.ReportController
|
||||
alias PhilomenaWeb.ReportView
|
||||
alias Philomena.Users.User
|
||||
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: User, id_name: "profile_id", id_field: "slug", persisted: true
|
||||
|
||||
def new(conn, _params) do
|
||||
user = conn.assigns.user
|
||||
action = Routes.profile_report_path(conn, :create, user)
|
||||
changeset =
|
||||
%Report{reportable_type: "User", reportable_id: user.id}
|
||||
|> Reports.change_report()
|
||||
|
||||
conn
|
||||
|> put_view(ReportView)
|
||||
|> render("new.html", reportable: user, changeset: changeset, action: action)
|
||||
end
|
||||
|
||||
def create(conn, params) do
|
||||
user = conn.assigns.user
|
||||
action = Routes.profile_report_path(conn, :create, user)
|
||||
|
||||
ReportController.create(conn, action, user, "User", params)
|
||||
end
|
||||
end
|
|
@ -165,7 +165,9 @@ defmodule PhilomenaWeb.Router do
|
|||
resources "/current", CurrentController, only: [:update], singleton: true
|
||||
end
|
||||
resources "/filters", FilterController
|
||||
resources "/profiles", ProfileController, only: [:show]
|
||||
resources "/profiles", ProfileController, only: [:show] do
|
||||
resources "/reports", Profile.ReportController, only: [:new, :create]
|
||||
end
|
||||
resources "/captchas", CaptchaController, only: [:create]
|
||||
scope "/posts", Post, as: :post do
|
||||
resources "/preview", PreviewController, only: [:create]
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
.profile-top__options
|
||||
ul.profile-top__options__column
|
||||
li = link("Send message", to: "#")
|
||||
li = link("Our conversations", to: "#")
|
||||
li = link("Report this user", to: "#")
|
||||
li = link("Send message", to: Routes.conversation_path(@conn, :new, recipient: @user.name))
|
||||
li = link("Our conversations", to: Routes.conversation_path(@conn, :index, with: @user.id))
|
||||
li = link("Report this user", to: Routes.profile_report_path(@conn, :new, @user))
|
||||
|
||||
ul.profile-top__options__column
|
||||
li = link("Uploads", to: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}"))
|
||||
|
|
Loading…
Reference in a new issue