58 lines
2.7 KiB
Diff
58 lines
2.7 KiB
Diff
|
diff --git a/lib/pleroma/web/metadata/providers/twitter_card.ex b/lib/pleroma/web/metadata/providers/twitter_card.ex
|
||
|
index 79183df86..563a18bd0 100644
|
||
|
--- a/lib/pleroma/web/metadata/providers/twitter_card.ex
|
||
|
+++ b/lib/pleroma/web/metadata/providers/twitter_card.ex
|
||
|
@@ -14,8 +14,12 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
|
||
|
@media_types ["image", "audio", "video"]
|
||
|
|
||
|
@impl Provider
|
||
|
- def build_tags(%{activity_id: id, object: object, user: user}) do
|
||
|
- attachments = build_attachments(id, object)
|
||
|
+ def build_tags(%{
|
||
|
+ object: object,
|
||
|
+ url: url,
|
||
|
+ user: user
|
||
|
+ }) do
|
||
|
+ attachments = build_attachments(object)
|
||
|
scrubbed_content = Utils.scrub_html_and_truncate(object)
|
||
|
|
||
|
[
|
||
|
@@ -53,7 +57,7 @@ def image_tag(user) do
|
||
|
[]}
|
||
|
end
|
||
|
|
||
|
- defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
||
|
+ defp build_attachments(%{data: %{"attachment" => attachments}}) do
|
||
|
Enum.reduce(attachments, [], fn attachment, acc ->
|
||
|
rendered_tags =
|
||
|
Enum.reduce(attachment["url"], [], fn url, acc ->
|
||
|
@@ -63,7 +67,7 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
||
|
{:meta, [property: "twitter:card", content: "player"], []},
|
||
|
{:meta, [property: "twitter:player:width", content: "480"], []},
|
||
|
{:meta, [property: "twitter:player:height", content: "80"], []},
|
||
|
- {:meta, [property: "twitter:player", content: player_url(id)], []}
|
||
|
+ {:meta, [property: "twitter:player", content: MediaProxy.url(url["href"])], []}
|
||
|
| acc
|
||
|
]
|
||
|
|
||
|
@@ -91,7 +95,7 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
||
|
|
||
|
[
|
||
|
{:meta, [property: "twitter:card", content: "player"], []},
|
||
|
- {:meta, [property: "twitter:player", content: player_url(id)], []},
|
||
|
+ {:meta, [property: "twitter:player", content: MediaProxy.url(url["href"])], []},
|
||
|
{:meta, [property: "twitter:player:width", content: "#{width}"], []},
|
||
|
{:meta, [property: "twitter:player:height", content: "#{height}"], []},
|
||
|
{:meta, [property: "twitter:player:stream", content: MediaProxy.url(url["href"])],
|
||
|
@@ -112,10 +116,6 @@ defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
|
||
|
|
||
|
defp build_attachments(_id, _object), do: []
|
||
|
|
||
|
- defp player_url(id) do
|
||
|
- Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice_player, id)
|
||
|
- end
|
||
|
-
|
||
|
# Videos have problems without dimensions, but we used to not provide WxH for images.
|
||
|
# A default (read: incorrect) fallback for images is likely to cause rendering bugs.
|
||
|
defp maybe_add_dimensions(metadata, url) do
|