X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fcollections%2Ffetcher.ex;h=0c81f0b56cbb3531d48be834747a15b0be66a9a1;hb=99ced95d3bf4b49246e6946568cdd31b4173a25f;hp=205c62b4eec89fb2686b7d4a03e92929759019e8;hpb=05081cd81be675db4825335181182dd110c4b834;p=akkoma diff --git a/lib/pleroma/collections/fetcher.ex b/lib/pleroma/collections/fetcher.ex index 205c62b4e..0c81f0b56 100644 --- a/lib/pleroma/collections/fetcher.ex +++ b/lib/pleroma/collections/fetcher.ex @@ -9,17 +9,27 @@ defmodule Akkoma.Collections.Fetcher do """ alias Pleroma.Object.Fetcher alias Pleroma.Config + require Logger def fetch_collection_by_ap_id(ap_id) when is_binary(ap_id) do fetch_collection(ap_id) end - defp fetch_collection(ap_id) do + def fetch_collection(ap_id) when is_binary(ap_id) do with {:ok, page} <- Fetcher.fetch_and_contain_remote_object_from_id(ap_id) do {:ok, objects_from_collection(page)} + else + e -> + Logger.error("Could not fetch collection #{ap_id} - #{inspect(e)}") + e end end + def fetch_collection(%{"type" => type} = page) + when type in ["Collection", "OrderedCollection"] do + {:ok, objects_from_collection(page)} + end + defp items_in_page(%{"type" => type, "orderedItems" => items}) when is_list(items) and type in ["OrderedCollection", "OrderedCollectionPage"], do: items