X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity.ex;h=07982331257d5c27ae22b324a6af9d9b07342812;hb=e369b1306b2f8b9732c21333b9957f7e4e408f90;hp=553834da0b786f905f1544fc9feb395c66bc0285;hpb=0d8cc0905aeebb965df0cf755a171d21b01ed978;p=akkoma diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 553834da0..079823312 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -194,6 +194,19 @@ defmodule Pleroma.Activity do end end + def get_by_id_with_user_actor(id) do + case FlakeId.flake_id?(id) do + true -> + Activity + |> where([a], a.id == ^id) + |> with_preloaded_user_actor() + |> Repo.one() + + _ -> + nil + end + end + def get_by_id_with_object(id) do Activity |> where(id: ^id) @@ -356,4 +369,15 @@ defmodule Pleroma.Activity do actor = user_actor(activity) activity.id in actor.pinned_activities end + + @spec get_by_object_ap_id_with_object(String.t()) :: t() | nil + def get_by_object_ap_id_with_object(ap_id) when is_binary(ap_id) do + ap_id + |> Queries.by_object_id() + |> with_preloaded_object() + |> first() + |> Repo.one() + end + + def get_by_object_ap_id_with_object(_), do: nil end