Merge remote-tracking branch 'upstream/develop' into feature/move-activity
[akkoma] / lib / pleroma / web / admin_api / report.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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 Enum.map(status_ap_ids, fn
17 act when is_map(act) -> Activity.get_by_ap_id_with_object(act["id"])
18 act when is_binary(act) -> Activity.get_by_ap_id_with_object(act)
19 end)
20
21 %{report: report, user: user, account: account, statuses: statuses}
22 end
23 end