From bfab5d210b80326ef8e6e7f9c92f4829430a90ca Mon Sep 17 00:00:00 2001 From: a1batross Date: Sat, 9 Jul 2022 02:46:58 +0200 Subject: [PATCH] Revert "activity_pub: fix case when featured collection misses orderedItems field" This reverts commit 8dc92d962b42f26da562d11f2d544994cb5a43f5. --- lib/pleroma/web/activity_pub/activity_pub.ex | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 3f4cd5ab3..179e6763b 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1682,19 +1682,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end - def pin_data_from_featured_collection(ap_id, %{"type" => type} = data) + def pin_data_from_featured_collection(%{ + "type" => type, + "orderedItems" => objects + }) when type in ["OrderedCollection", "Collection"] do - objects = Map.get(data, "orderedItems", nil) - - if is_list(objects) do - Map.new(objects, fn - %{"id" => object_ap_id} -> {object_ap_id, NaiveDateTime.utc_now()} - object_ap_id when is_binary(object_ap_id) -> {object_ap_id, NaiveDateTime.utc_now()} - end) - else - Logger.error("Could not decode featured collection at #{ap_id}, #{inspect(data)}") - %{} - end + Map.new(objects, fn + %{"id" => object_ap_id} -> {object_ap_id, NaiveDateTime.utc_now()} + object_ap_id when is_binary(object_ap_id) -> {object_ap_id, NaiveDateTime.utc_now()} + end) end def fetch_and_prepare_featured_from_ap_id(nil) do @@ -1703,7 +1699,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do def fetch_and_prepare_featured_from_ap_id(ap_id) do with {:ok, data} <- Fetcher.fetch_and_contain_remote_object_from_id(ap_id) do - {:ok, pin_data_from_featured_collection(ap_id, data)} + {:ok, pin_data_from_featured_collection(data)} else e -> Logger.error("Could not decode featured collection at fetch #{ap_id}, #{inspect(e)}")