projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'stable' into develop
[akkoma]
/
lib
/
pleroma
/
web
/
admin_api
/
controllers
/
report_controller.ex
diff --git
a/lib/pleroma/web/admin_api/controllers/report_controller.ex
b/lib/pleroma/web/admin_api/controllers/report_controller.ex
index 4c011e174539b9898249907f8b02948539dcf1e9..d4a4935eec829bdb57fce6536ee720cef2ad7493 100644
(file)
--- a/
lib/pleroma/web/admin_api/controllers/report_controller.ex
+++ b/
lib/pleroma/web/admin_api/controllers/report_controller.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ReportController do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ReportController do
@@
-9,21
+9,21
@@
defmodule Pleroma.Web.AdminAPI.ReportController do
alias Pleroma.Activity
alias Pleroma.ModerationLog
alias Pleroma.Activity
alias Pleroma.ModerationLog
- alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.ReportNote
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.AdminAPI
alias Pleroma.Web.AdminAPI.Report
alias Pleroma.Web.CommonAPI
alias Pleroma.ReportNote
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.AdminAPI
alias Pleroma.Web.AdminAPI.Report
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.Plugs.OAuthScopesPlug
require Logger
plug(Pleroma.Web.ApiSpec.CastAndValidate)
require Logger
plug(Pleroma.Web.ApiSpec.CastAndValidate)
- plug(OAuthScopesPlug, %{scopes: ["
read:reports"], admin: true
} when action in [:index, :show])
+ plug(OAuthScopesPlug, %{scopes: ["
admin:read:reports"]
} when action in [:index, :show])
plug(
OAuthScopesPlug,
plug(
OAuthScopesPlug,
- %{scopes: ["
write:reports"], admin: true
}
+ %{scopes: ["
admin:write:reports"]
}
when action in [:update, :notes_create, :notes_delete]
)
when action in [:update, :notes_create, :notes_delete]
)
@@
-38,7
+38,7
@@
defmodule Pleroma.Web.AdminAPI.ReportController do
end
def show(conn, %{id: id}) do
end
def show(conn, %{id: id}) do
- with %Activity{} = report <- Activity.get_
by_id
(id) do
+ with %Activity{} = report <- Activity.get_
report
(id) do
render(conn, "show.json", Report.extract_report_info(report))
else
_ -> {:error, :not_found}
render(conn, "show.json", Report.extract_report_info(report))
else
_ -> {:error, :not_found}
@@
-50,10
+50,13
@@
defmodule Pleroma.Web.AdminAPI.ReportController do
Enum.map(reports, fn report ->
case CommonAPI.update_report_state(report.id, report.state) do
{:ok, activity} ->
Enum.map(reports, fn report ->
case CommonAPI.update_report_state(report.id, report.state) do
{:ok, activity} ->
+ report = Activity.get_by_id_with_user_actor(activity.id)
+
ModerationLog.insert_log(%{
action: "report_update",
actor: admin,
ModerationLog.insert_log(%{
action: "report_update",
actor: admin,
- subject: activity
+ subject: activity,
+ subject_actor: report.user_actor
})
activity
})
activity
@@
-73,11
+76,13
@@
defmodule Pleroma.Web.AdminAPI.ReportController do
def notes_create(%{assigns: %{user: user}, body_params: %{content: content}} = conn, %{
id: report_id
}) do
def notes_create(%{assigns: %{user: user}, body_params: %{content: content}} = conn, %{
id: report_id
}) do
- with {:ok, _} <- ReportNote.create(user.id, report_id, content) do
+ with {:ok, _} <- ReportNote.create(user.id, report_id, content),
+ report <- Activity.get_by_id_with_user_actor(report_id) do
ModerationLog.insert_log(%{
action: "report_note",
actor: user,
ModerationLog.insert_log(%{
action: "report_note",
actor: user,
- subject: Activity.get_by_id(report_id),
+ subject: report,
+ subject_actor: report.user_actor,
text: content
})
text: content
})
@@
-91,11
+96,13
@@
defmodule Pleroma.Web.AdminAPI.ReportController do
id: note_id,
report_id: report_id
}) do
id: note_id,
report_id: report_id
}) do
- with {:ok, note} <- ReportNote.destroy(note_id) do
+ with {:ok, note} <- ReportNote.destroy(note_id),
+ report <- Activity.get_by_id_with_user_actor(report_id) do
ModerationLog.insert_log(%{
action: "report_note_delete",
actor: user,
ModerationLog.insert_log(%{
action: "report_note_delete",
actor: user,
- subject: Activity.get_by_id(report_id),
+ subject: report,
+ subject_actor: report.user_actor,
text: note.content
})
text: note.content
})