Fix tagpolicy to also work with Update
[akkoma] / lib / pleroma / web / admin_api / report.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.AdminAPI.Report do
6 alias Pleroma.Activity
7 alias Pleroma.User
8
9 def extract_report_info(
10 %{data: %{"actor" => actor, "object" => [account_ap_id | status_ap_ids]}} = report
11 ) do
12 user = User.get_cached_by_ap_id(actor)
13 account = User.get_cached_by_ap_id(account_ap_id)
14
15 statuses =
16 status_ap_ids
17 |> Enum.reject(&is_nil(&1))
18 |> Enum.map(fn
19 act when is_map(act) -> Activity.get_by_ap_id_with_object(act["id"])
20 act when is_binary(act) -> Activity.get_by_ap_id_with_object(act)
21 end)
22
23 %{report: report, user: user, account: account, statuses: statuses}
24 end
25 end