From f0a99b4595f11c8415155ffa32d4653db11c7bae Mon Sep 17 00:00:00 2001 From: Oneric Date: Mon, 10 Feb 2025 04:40:51 +0100 Subject: [PATCH] article_note_validator: fix handling of Mastodon-style replies collections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first collection page is (sometimes?) inlined which caused crashes when attempting to log the fetch failure. But there’s no need to fetch and we can treat it like the other inline collection --- .../object_validators/article_note_page_validator.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex index d1cd496db..e52986502 100644 --- a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex @@ -71,7 +71,7 @@ defp fix_tag(data), do: Map.drop(data, ["tag"]) defp fix_replies(%{"replies" => replies} = data) when is_list(replies), do: data - defp fix_replies(%{"replies" => %{"first" => first}} = data) do + defp fix_replies(%{"replies" => %{"first" => first}} = data) when is_binary(first) do with {:ok, replies} <- Akkoma.Collections.Fetcher.fetch_collection(first) do Map.put(data, "replies", replies) else @@ -81,6 +81,10 @@ defp fix_replies(%{"replies" => %{"first" => first}} = data) do end end + defp fix_replies(%{"replies" => %{"first" => %{"items" => replies}}} = data) + when is_list(replies), + do: Map.put(data, "replies", replies) + defp fix_replies(%{"replies" => %{"items" => replies}} = data) when is_list(replies), do: Map.put(data, "replies", replies)