From 33e7ae7637236b859bfabc9016a86e4bbe1e0632 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Mon, 17 Jul 2023 20:03:31 +0100 Subject: [PATCH] Allow nil attachments --- lib/pleroma/web/activity_pub/transmogrifier.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 5c96bf060..742dcb385 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -919,9 +919,13 @@ def add_attributed_to(object) do end def prepare_attachments(object) do + attachments = case Map.get(object, "attachment", []) do + [_ | _] = list -> list + _ -> [] + end + attachments = - object - |> Map.get("attachment", []) + attachments |> Enum.map(fn data -> [%{"mediaType" => media_type, "href" => href} = url | _] = data["url"]