logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

report.ex (1737B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.AdminAPI.Report do
  5. alias Pleroma.Activity
  6. alias Pleroma.Object
  7. alias Pleroma.User
  8. def extract_report_info(
  9. %{data: %{"actor" => actor, "object" => [account_ap_id | status_ap_ids]}} = report
  10. ) do
  11. user = User.get_cached_by_ap_id(actor)
  12. account = User.get_cached_by_ap_id(account_ap_id)
  13. statuses =
  14. status_ap_ids
  15. |> Enum.reject(&is_nil(&1))
  16. |> Enum.map(fn
  17. act when is_map(act) ->
  18. Activity.get_create_by_object_ap_id_with_object(act["id"]) ||
  19. Activity.get_by_ap_id_with_object(act["id"]) || make_fake_activity(act, user)
  20. act when is_binary(act) ->
  21. Activity.get_create_by_object_ap_id_with_object(act) ||
  22. Activity.get_by_ap_id_with_object(act)
  23. end)
  24. %{report: report, user: user, account: account, statuses: statuses}
  25. end
  26. defp make_fake_activity(act, user) do
  27. %Activity{
  28. id: "pleroma:fake:#{act["id"]}",
  29. data: %{
  30. "actor" => user.ap_id,
  31. "type" => "Create",
  32. "to" => [],
  33. "cc" => [],
  34. "object" => act["id"],
  35. "published" => act["published"],
  36. "id" => act["id"],
  37. "context" => "pleroma:fake"
  38. },
  39. recipients: [user.ap_id],
  40. object: %Object{
  41. data: %{
  42. "actor" => user.ap_id,
  43. "type" => "Note",
  44. "content" => act["content"],
  45. "published" => act["published"],
  46. "to" => [],
  47. "cc" => [],
  48. "id" => act["id"],
  49. "context" => "pleroma:fake"
  50. }
  51. }
  52. }
  53. end
  54. end