Implement report notes destruction
This commit is contained in:
parent
08c89fd2b8
commit
a7f77785c2
7 changed files with 88 additions and 18 deletions
|
|
@ -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"])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue