Embed player suitable for Twitter Cards

This commit is contained in:
href 2019-02-19 17:39:42 +01:00
commit 10a11f083c
No known key found for this signature in database
GPG key ID: EE8296C1A152C325
5 changed files with 71 additions and 6 deletions

View file

@ -153,6 +153,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%Object{} = object = Object.normalize(activity.data["object"])
Fallback.RedirectController.redirector_with_meta(conn, %{
activity_id: activity.id,
object: object,
url:
Pleroma.Web.Router.Helpers.o_status_url(
@ -184,6 +185,25 @@ defmodule Pleroma.Web.OStatus.OStatusController do
end
end
# Returns an HTML embedded <audio> or <video> player suitable for embed iframes.
def notice_player(conn, %{"id" => id}) do
with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id(id),
true <- ActivityPub.is_public?(activity),
%Object{} = object <- Object.normalize(activity.data["object"]),
%{data: %{"attachment" => [%{"url" => [url | _]} | _]}} <- object,
true <- String.starts_with?(url["mediaType"], ["audio", "video"]) do
conn
|> put_layout(:metadata_player)
|> put_view(Pleroma.Web.Metadata.PlayerView)
|> render("player.html", url)
else
_error ->
conn
|> put_status(404)
|> Fallback.RedirectController.redirector(nil, 404)
end
end
defp represent_activity(
conn,
"activity+json",