2019-09-23 22:33:59 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2019-09-23 22:33:59 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.AdminAPI.Report do
|
|
|
|
alias Pleroma.Activity
|
2022-11-10 03:36:42 +00:00
|
|
|
alias Pleroma.Object
|
2019-09-23 22:33:59 +00:00
|
|
|
alias Pleroma.User
|
|
|
|
|
|
|
|
def extract_report_info(
|
|
|
|
%{data: %{"actor" => actor, "object" => [account_ap_id | status_ap_ids]}} = report
|
|
|
|
) do
|
|
|
|
user = User.get_cached_by_ap_id(actor)
|
|
|
|
account = User.get_cached_by_ap_id(account_ap_id)
|
|
|
|
|
|
|
|
statuses =
|
2021-08-11 14:38:16 +00:00
|
|
|
status_ap_ids
|
|
|
|
|> Enum.reject(&is_nil(&1))
|
|
|
|
|> Enum.map(fn
|
2022-11-10 03:36:42 +00:00
|
|
|
act when is_map(act) ->
|
2022-11-20 05:35:52 +00:00
|
|
|
Activity.get_create_by_object_ap_id_with_object(act["id"]) ||
|
|
|
|
Activity.get_by_ap_id_with_object(act["id"]) || make_fake_activity(act, user)
|
2022-11-10 03:36:42 +00:00
|
|
|
|
|
|
|
act when is_binary(act) ->
|
2022-11-20 05:35:52 +00:00
|
|
|
Activity.get_create_by_object_ap_id_with_object(act) ||
|
|
|
|
Activity.get_by_ap_id_with_object(act)
|
2019-09-23 22:33:59 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
%{report: report, user: user, account: account, statuses: statuses}
|
|
|
|
end
|
2022-11-10 03:36:42 +00:00
|
|
|
|
|
|
|
defp make_fake_activity(act, user) do
|
|
|
|
%Activity{
|
2023-02-03 20:38:08 +00:00
|
|
|
id: "pleroma:fake:#{act["id"]}",
|
2022-11-10 03:36:42 +00:00
|
|
|
data: %{
|
|
|
|
"actor" => user.ap_id,
|
|
|
|
"type" => "Create",
|
|
|
|
"to" => [],
|
|
|
|
"cc" => [],
|
|
|
|
"object" => act["id"],
|
2022-11-10 04:02:27 +00:00
|
|
|
"published" => act["published"],
|
|
|
|
"id" => act["id"],
|
|
|
|
"context" => "pleroma:fake"
|
2022-11-10 03:36:42 +00:00
|
|
|
},
|
|
|
|
recipients: [user.ap_id],
|
|
|
|
object: %Object{
|
|
|
|
data: %{
|
|
|
|
"actor" => user.ap_id,
|
|
|
|
"type" => "Note",
|
|
|
|
"content" => act["content"],
|
|
|
|
"published" => act["published"],
|
|
|
|
"to" => [],
|
2022-11-10 04:02:27 +00:00
|
|
|
"cc" => [],
|
|
|
|
"id" => act["id"],
|
|
|
|
"context" => "pleroma:fake"
|
2022-11-10 03:36:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2019-09-23 22:33:59 +00:00
|
|
|
end
|