CommonAPI: generate ModerationLog for all admin/moderator deletes
As a side-effect it also changes the ChatMessage delete ID to an Activity.id rather than MessageReference.id Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/2958
This commit is contained in:
parent
c830282628
commit
16b06160ac
5 changed files with 41 additions and 27 deletions
|
|
@ -8,7 +8,6 @@ defmodule Pleroma.Web.AdminAPI.ChatController do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.Chat
|
||||
alias Pleroma.Chat.MessageReference
|
||||
alias Pleroma.ModerationLog
|
||||
alias Pleroma.Pagination
|
||||
alias Pleroma.Web.AdminAPI
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -42,12 +41,6 @@ defmodule Pleroma.Web.AdminAPI.ChatController do
|
|||
^chat_id <- to_string(cm_ref.chat_id),
|
||||
%Activity{id: activity_id} <- Activity.get_create_by_object_ap_id(object_ap_id),
|
||||
{:ok, _} <- CommonAPI.delete(activity_id, user) do
|
||||
ModerationLog.insert_log(%{
|
||||
action: "chat_message_delete",
|
||||
actor: user,
|
||||
subject_id: message_id
|
||||
})
|
||||
|
||||
conn
|
||||
|> put_view(MessageReferenceView)
|
||||
|> render("show.json", chat_message_reference: cm_ref)
|
||||
|
|
|
|||
|
|
@ -65,12 +65,6 @@ defmodule Pleroma.Web.AdminAPI.StatusController do
|
|||
|
||||
def delete(%{assigns: %{user: user}} = conn, %{id: id}) do
|
||||
with {:ok, %Activity{}} <- CommonAPI.delete(id, user) do
|
||||
ModerationLog.insert_log(%{
|
||||
action: "status_delete",
|
||||
actor: user,
|
||||
subject_id: id
|
||||
})
|
||||
|
||||
json(conn, %{})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Formatter
|
||||
alias Pleroma.ModerationLog
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.ThreadMute
|
||||
alias Pleroma.User
|
||||
|
|
@ -147,6 +148,21 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
true <- User.superuser?(user) || user.ap_id == object.data["actor"],
|
||||
{:ok, delete_data, _} <- Builder.delete(user, object.data["id"]),
|
||||
{:ok, delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
|
||||
if User.superuser?(user) and user.ap_id != object.data["actor"] do
|
||||
action =
|
||||
if object.data["type"] == "ChatMessage" do
|
||||
"chat_message_delete"
|
||||
else
|
||||
"status_delete"
|
||||
end
|
||||
|
||||
ModerationLog.insert_log(%{
|
||||
action: action,
|
||||
actor: user,
|
||||
subject_id: activity_id
|
||||
})
|
||||
end
|
||||
|
||||
{:ok, delete}
|
||||
else
|
||||
{:find_activity, _} ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue