summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-12 16:16:10 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-12 16:16:10 -0500
commit02b9436494998e441fe2119b78c0e4f68c45a9e1 (patch)
tree7886fc5a7a66ac07817d0885a791de48bec4db91
parent4c060ae73371a8567468186e5d1333ec00fbdf41 (diff)
Don't render media `meta` if nil
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 5dbdc309e..7f318e81b 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
alias Pleroma.Activity
alias Pleroma.HTML
+ alias Pleroma.Maps
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
@@ -406,6 +407,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
media_type = attachment_url["mediaType"] || attachment_url["mimeType"] || "image"
href = attachment_url["href"] |> MediaProxy.url()
href_preview = attachment_url["href"] |> MediaProxy.preview_url()
+ meta = render("attachment_meta.json", %{attachment: attachment})
type =
cond do
@@ -426,9 +428,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
type: type,
description: attachment["name"],
pleroma: %{mime_type: media_type},
- meta: render("attachment_meta.json", %{attachment: attachment}),
blurhash: attachment["blurhash"]
}
+ |> Maps.put_if_present(:meta, meta)
end
def render("attachment_meta.json", %{
@@ -444,7 +446,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
}
end
- def render("attachment_meta.json", _), do: %{}
+ def render("attachment_meta.json", _), do: nil
def render("context.json", %{activity: activity, activities: activities, user: user}) do
%{ancestors: ancestors, descendants: descendants} =