From 1cc8bb393c37c10e438ca97070f276b4e2ed5d10 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 25 Mar 2018 17:07:40 +0200 Subject: [PATCH] Render peertube videos in mastodon. --- lib/pleroma/web/mastodon_api/views/status_view.ex | 8 ++++++-- 1 file changed, 6 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 170b6ac6c..a9594ccf9 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -68,7 +68,9 @@ 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) + attachment_data = object["attachment"] || [] + attachment_data = attachment_data ++ (if object["type"] == "Video", do: [object], else: []) + attachments = render_many(attachment_data, StatusView, "attachment.json", as: :attachment) created_at = Utils.to_masto_date(object["published"]) @@ -126,7 +128,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do end def render("attachment.json", %{attachment: attachment}) do - [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"] + [attachment | _] = attachment["url"] + media_type = attachment["mediaType"] || attachment["mimeType"] + href = attachment["href"] type = cond do String.contains?(media_type, "image") -> "image"