projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
78047d5
)
html: add utility function to extract first URL from an object and cache the result
author
William Pitcock
<nenolod@dereferenced.org>
Sat, 26 Jan 2019 14:55:12 +0000
(14:55 +0000)
committer
William Pitcock
<nenolod@dereferenced.org>
Sat, 26 Jan 2019 14:55:12 +0000
(14:55 +0000)
lib/pleroma/html.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/html.ex
b/lib/pleroma/html.ex
index f5c6e5033fb572b0f02e717101dceafbd3c394c9..fb602d6b6186335f1b4174f59fd6e70de9036648 100644
(file)
--- a/
lib/pleroma/html.ex
+++ b/
lib/pleroma/html.ex
@@
-58,6
+58,20
@@
defmodule Pleroma.HTML do
"#{signature}#{to_string(scrubber)}"
end)
end
+
+ 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, result}
+ end)
+ end
end
defmodule Pleroma.HTML.Scrubber.TwitterText do