projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9aa69e1
)
cache HTML in OGP
author
rinpatch
<rinpatch@sdf.org>
Tue, 15 Jan 2019 21:07:28 +0000
(
00:07
+0300)
committer
rinpatch
<rinpatch@sdf.org>
Tue, 15 Jan 2019 21:07:28 +0000
(
00:07
+0300)
lib/pleroma/web/metadata/opengraph.ex
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/metadata/opengraph.ex
b/lib/pleroma/web/metadata/opengraph.ex
index 1e3af947d6755d27b04f0bdd4bd53f5ce779d102..33ff075c64bb4c7a1da955227bf1380faeb9c819 100644
(file)
--- a/
lib/pleroma/web/metadata/opengraph.ex
+++ b/
lib/pleroma/web/metadata/opengraph.ex
@@
-7,7
+7,7
@@
defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
@impl Provider
def build_tags(%{activity: activity, user: user}) do
@impl Provider
def build_tags(%{activity: activity, user: user}) do
- with truncated_content = scrub_html_and_truncate(activity
.data["object"]["content"]
) do
+ with truncated_content = scrub_html_and_truncate(activity) do
attachments = build_attachments(activity)
[
attachments = build_attachments(activity)
[
@@
-71,6
+71,15
@@
defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
end)
end
end)
end
+ defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} = activity) do
+ content
+ # html content comes from DB already encoded, decode first and scrub after
+ |> HtmlEntities.decode()
+ |> String.replace(~r/<br\s?\/?>/, " ")
+ |> HTML.get_cached_stripped_html_for_object(activity, __MODULE__)
+ |> Formatter.truncate()
+ end
+
defp scrub_html_and_truncate(content) do
content
# html content comes from DB already encoded, decode first and scrub after
defp scrub_html_and_truncate(content) do
content
# html content comes from DB already encoded, decode first and scrub after
@@
-79,7
+88,6
@@
defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
|> HTML.strip_tags()
|> Formatter.truncate()
end
|> HTML.strip_tags()
|> Formatter.truncate()
end
-
defp attachment_url(url) do
MediaProxy.url(url)
end
defp attachment_url(url) do
MediaProxy.url(url)
end