rename outbox/pin fetching functions to be more generic
Some checks are pending
ci/woodpecker/pr/build-amd64 Pipeline is pending approval
ci/woodpecker/pr/build-arm64 Pipeline is pending approval
ci/woodpecker/pr/docs Pipeline is pending approval
ci/woodpecker/pr/lint Pipeline is pending approval
ci/woodpecker/pr/test Pipeline is pending approval
Some checks are pending
ci/woodpecker/pr/build-amd64 Pipeline is pending approval
ci/woodpecker/pr/build-arm64 Pipeline is pending approval
ci/woodpecker/pr/docs Pipeline is pending approval
ci/woodpecker/pr/lint Pipeline is pending approval
ci/woodpecker/pr/test Pipeline is pending approval
This commit is contained in:
parent
5c44cd478b
commit
0123d24ad9
3 changed files with 12 additions and 12 deletions
|
@ -1576,7 +1576,7 @@ defp object_to_user_data(data, additional) do
|
|||
actor_type = data["type"] || "Person"
|
||||
|
||||
featured_address = data["featured"]
|
||||
{:ok, pinned_objects} = fetch_and_prepare_outbox_from_ap_id(featured_address)
|
||||
{:ok, pinned_objects} = fetch_and_prepare_collection_from_ap_id(featured_address)
|
||||
outbox_address = data["outbox"]
|
||||
|
||||
public_key =
|
||||
|
@ -1774,7 +1774,7 @@ def maybe_handle_clashing_nickname(data) do
|
|||
end
|
||||
end
|
||||
|
||||
def activity_data_from_outbox_collection(%{
|
||||
def activity_data_from_collection(%{
|
||||
"type" => "OrderedCollection",
|
||||
"first" => first
|
||||
}) do
|
||||
|
@ -1789,7 +1789,7 @@ def activity_data_from_outbox_collection(%{
|
|||
end
|
||||
end
|
||||
|
||||
def activity_data_from_outbox_collection(
|
||||
def activity_data_from_collection(
|
||||
%{
|
||||
"type" => type
|
||||
} = collection
|
||||
|
@ -1805,23 +1805,23 @@ def activity_data_from_outbox_collection(
|
|||
end)
|
||||
end
|
||||
|
||||
def activity_data_from_outbox_collection(obj) do
|
||||
Logger.error("Could not parse outbox collection #{inspect(obj)}")
|
||||
def activity_data_from_collection(obj) do
|
||||
Logger.error("Could not parse collection #{inspect(obj)}")
|
||||
%{}
|
||||
end
|
||||
|
||||
def fetch_and_prepare_outbox_from_ap_id(nil) do
|
||||
def fetch_and_prepare_collection_from_ap_id(nil) do
|
||||
{:ok, %{}}
|
||||
end
|
||||
|
||||
def fetch_and_prepare_outbox_from_ap_id(ap_id) do
|
||||
Logger.info("Fetching outbox #{ap_id}")
|
||||
def fetch_and_prepare_collection_from_ap_id(ap_id) do
|
||||
Logger.info("Fetching collection #{ap_id}")
|
||||
|
||||
with {:ok, data} <- Fetcher.fetch_and_contain_remote_object_from_id(ap_id) do
|
||||
{:ok, activity_data_from_outbox_collection(data)}
|
||||
{:ok, activity_data_from_collection(data)}
|
||||
else
|
||||
e ->
|
||||
Logger.error("Could not decode outbox collection at fetch #{ap_id}, #{inspect(e)}")
|
||||
Logger.error("Could not decode collection at fetch #{ap_id}, #{inspect(e)}")
|
||||
{:ok, %{}}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -640,7 +640,7 @@ defp handle_incoming_normalised(
|
|||
defp handle_incoming_normalised(%{"object" => o, "_akkoma_fake" => true}, options),
|
||||
do: handle_incoming_normalised(o, options)
|
||||
|
||||
defp handle_incoming_normalised(o, _), do: :error
|
||||
defp handle_incoming_normalised(_, _), do: :error
|
||||
|
||||
@spec get_obj_helper(String.t(), Keyword.t()) :: {:ok, Object.t()} | nil
|
||||
def get_obj_helper(id, options \\ []) do
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Workers.RemoteFetcherWorker do
|
|||
@impl Oban.Worker
|
||||
|
||||
def perform(%Job{args: %{"op" => "fetch_outbox", "id" => address}}) do
|
||||
with {:ok, outbox} <- ActivityPub.fetch_and_prepare_outbox_from_ap_id(address) do
|
||||
with {:ok, outbox} <- ActivityPub.fetch_and_prepare_collection_from_ap_id(address) do
|
||||
Enum.each(Enum.reverse(outbox), fn {ap_id, _} ->
|
||||
if is_nil(Object.get_cached_by_ap_id(ap_id)) do
|
||||
perform(%{
|
||||
|
|
Loading…
Reference in a new issue