1
0
Fork 0
mirror of https://git.pleroma.social/pleroma/pleroma.git synced 2026-02-15 17:16:57 +00:00

Make OEmbed discovery work

This commit is contained in:
Alex Gleason 2021-05-04 11:06:10 -05:00
parent 765bdfca7d
commit b045dc6058
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
4 changed files with 6 additions and 3 deletions

View file

@ -158,7 +158,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
|> maybe_parse()
|> Map.put("url", url)
|> clean_parsed_data()
|> Card.from_meta_tags(url)
|> Card.from_discovery(url)
|> check_card()
end
end

View file

@ -41,7 +41,7 @@ defmodule Pleroma.Web.RichMedia.Parser.Card do
def from_oembed(_oembed, _url), do: nil
def from_meta_tags(rich_media, page_url) do
def from_discovery(%{"type" => "link"} = rich_media, page_url) do
page_url_data = URI.parse(page_url)
page_url_data =
@ -70,6 +70,8 @@ defmodule Pleroma.Web.RichMedia.Parser.Card do
}
end
def from_discovery(rich_media, url), do: from_oembed(rich_media, url)
defp proxy(url) when is_binary(url), do: Pleroma.Web.MediaProxy.url(url)
defp proxy(_), do: nil
end

View file

@ -22,7 +22,7 @@ defmodule Pleroma.Web.RichMedia.Parsers.OEmbed do
end
defp get_oembed_data(url) do
with {:ok, %Tesla.Env{body: json}} <- Pleroma.Web.RichMedia.Helpers.rich_media_get(url) do
with {:ok, %Tesla.Env{body: json}} <- Pleroma.Web.RichMedia.Helpers.oembed_get(url) do
Jason.decode(json)
end
end

View file

@ -11,5 +11,6 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCard do
|> MetaTagsParser.parse(html, "og", "property")
|> MetaTagsParser.parse(html, "twitter", "name")
|> MetaTagsParser.parse(html, "twitter", "property")
|> Map.put("type", "link")
end
end