hopefully fix akkoma previews
This commit is contained in:
parent
13fb688d5b
commit
aa1d981529
2 changed files with 58 additions and 0 deletions
57
akkoma/change-twitter-preview.patch
Normal file
57
akkoma/change-twitter-preview.patch
Normal file
|
@ -0,0 +1,57 @@
|
|||
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
|
|
@ -25,6 +25,7 @@
|
|||
./jxl-polyfill.patch
|
||||
./block-invalid-datetime-mrf.patch
|
||||
./require-image-description.patch
|
||||
./change-twitter-preview.patch
|
||||
];
|
||||
};
|
||||
in
|
||||
|
|
Reference in a new issue