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:
parent
765bdfca7d
commit
b045dc6058
4 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue