X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fhtml.ex;h=b4a4742ee30c39699e0ecaf079a8226415ead5f3;hb=09b71a9053fe66ba8f4fca940f22eaffbf4af215;hp=f5c6e5033fb572b0f02e717101dceafbd3c394c9;hpb=608cc65d43277016a22500771360598775a3df1e;p=akkoma diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index f5c6e5033..b4a4742ee 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -58,6 +58,22 @@ defmodule Pleroma.HTML do "#{signature}#{to_string(scrubber)}" end) end + + def extract_first_external_url(_, nil), do: {:error, "No content"} + + def extract_first_external_url(object, content) do + key = "URL|#{object.id}" + + Cachex.fetch!(:scrubber_cache, key, fn _key -> + result = + content + |> Floki.filter_out("a.mention") + |> Floki.attribute("a", "href") + |> Enum.at(0) + + {:commit, {:ok, result}} + end) + end end defmodule Pleroma.HTML.Scrubber.TwitterText do