X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fviews%2Fstatus_view.ex;h=686ffd29de26e6d4db5f2c6c554095ff163f591d;hb=fc10875895abd9add5a7834c4b5a64cc5b9401f8;hp=7b798506a08937ab66bbabde10e0e755b3d1dd42;hpb=454dc1857074c8a98b4fada6d65ed4a810f1c501;p=akkoma diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 7b798506a..686ffd29d 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -24,6 +24,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || []) favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || []) + attachments = render_many(object["attachment"] || [], StatusView, "attachment.json", as: :attachment) + %{ id: activity.id, uri: object["id"], @@ -42,11 +44,29 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do sensitive: sensitive, spoiler_text: "", visibility: "public", - media_attachments: [], # fix + media_attachments: attachments, mentions: mentions, tags: [], # fix, application: nil, language: nil } end + + def render("attachment.json", %{attachment: attachment}) do + [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"] + + type = cond do + String.contains?(media_type, "image") -> "image" + String.contains?(media_type, "video") -> "video" + true -> "unknown" + end + + %{ + id: attachment["uuid"], + url: href, + remote_url: href, + preview_url: href, + type: type + } + end end