Skip to content

Commit

Permalink
StatusView: Fall back to attachment type if no mimetype present
Browse files Browse the repository at this point in the history
Signed-off-by: marcin mikołajczak <[email protected]>
  • Loading branch information
mkljczk committed Sep 7, 2024
1 parent d1daa9a commit 1463ecc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/pleroma/web/mastodon_api/views/status_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do

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()
Expand All @@ -615,6 +616,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView 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

Expand Down

0 comments on commit 1463ecc

Please sign in to comment.