aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/admin_api
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-12-08 11:27:23 +0300
committerMaxim Filippov <colixer@gmail.com>2019-12-08 11:27:23 +0300
commita7f77785c2675b5f9f7ede85e92ec50444945e54 (patch)
tree9397e4d00fa8193717fef41b921d820eb5bb9de9 /lib/pleroma/web/admin_api
parent08c89fd2b89614baaf4bfce067cfec9db96f2d2c (diff)
downloadpleroma-a7f77785c2675b5f9f7ede85e92ec50444945e54.tar.gz
Implement report notes destruction
Diffstat (limited to 'lib/pleroma/web/admin_api')
-rw-r--r--lib/pleroma/web/admin_api/admin_api_controller.ex26
-rw-r--r--lib/pleroma/web/admin_api/views/report_view.ex10
2 files changed, 30 insertions, 6 deletions
diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex
index ee32bac45..d34952cda 100644
--- a/lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/admin_api_controller.ex
@@ -691,14 +691,14 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
end
def report_notes_create(%{assigns: %{user: user}} = conn, %{
- "id" => status_id,
+ "id" => report_id,
"content" => content
}) do
- with {:ok, _} <- ReportNote.create(user.id, status_id, content) do
+ with {:ok, _} <- ReportNote.create(user.id, report_id, content) do
ModerationLog.insert_log(%{
- action: "report_response",
+ action: "report_note",
actor: user,
- subject: Activity.get_by_id(status_id),
+ subject: Activity.get_by_id(report_id),
text: content
})
@@ -708,6 +708,24 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
end
end
+ def report_notes_delete(%{assigns: %{user: user}} = conn, %{
+ "id" => note_id,
+ "report_id" => report_id
+ }) do
+ with {:ok, note} <- ReportNote.destroy(note_id) do
+ ModerationLog.insert_log(%{
+ action: "report_note_delete",
+ actor: user,
+ subject: Activity.get_by_id(report_id),
+ text: note.content
+ })
+
+ json_response(conn, :no_content, "")
+ else
+ _ -> json_response(conn, :bad_request, "")
+ end
+ end
+
def status_update(%{assigns: %{user: admin}} = conn, %{"id" => id} = params) do
with {:ok, activity} <- CommonAPI.update_activity_scope(id, params) do
{:ok, sensitive} = Ecto.Type.cast(:boolean, params["sensitive"])
diff --git a/lib/pleroma/web/admin_api/views/report_view.ex b/lib/pleroma/web/admin_api/views/report_view.ex
index f5c6ba401..294861044 100644
--- a/lib/pleroma/web/admin_api/views/report_view.ex
+++ b/lib/pleroma/web/admin_api/views/report_view.ex
@@ -69,13 +69,19 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
def render("index_notes.json", _), do: []
- def render("show_note.json", %{content: content, user_id: user_id, inserted_at: inserted_at}) do
+ def render("show_note.json", %{
+ id: id,
+ content: content,
+ user_id: user_id,
+ inserted_at: inserted_at
+ }) do
user = User.get_by_id(user_id)
%{
+ id: id,
content: content,
user: merge_account_views(user),
- created_at: inserted_at
+ created_at: Utils.to_masto_date(inserted_at)
}
end