From 1463eccf93d37e5aa2d8e4425f5bd394ba96a022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 7 Sep 2024 14:10:47 +0200 Subject: [PATCH] StatusView: Fall back to attachment type if no mimetype present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- lib/pleroma/web/mastodon_api/views/status_view.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 3ec5d8238f..a91f62d6e5 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -604,6 +604,7 @@ def render("card.json", _), do: nil def render("attachment.json", %{attachment: attachment}) do [attachment_url | _] = attachment["url"] + attachment_type = attachment["type"] media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image" href_remote = attachment_url["href"] href = href_remote |> MediaProxy.url() @@ -615,6 +616,7 @@ def render("attachment.json", %{attachment: attachment}) do String.contains?(media_type, "image") -> "image" String.contains?(media_type, "video") -> "video" String.contains?(media_type, "audio") -> "audio" + attachment_type in ~w[Audio Image Video] -> attachment_type |> String.downcase() true -> "unknown" end