mandate published on notes
[akkoma] / lib / pleroma / web / metadata / utils.ex
index bc31d66b9a7162b79cbee3c0c121f9df9709bcf4..8990bef543aae34ba0662e0b20e80d80fd765586 100644 (file)
@@ -7,10 +7,9 @@ defmodule Pleroma.Web.Metadata.Utils do
   alias Pleroma.Emoji
   alias Pleroma.Formatter
   alias Pleroma.HTML
-  alias Pleroma.Web.MediaProxy
 
-  def scrub_html_and_truncate(%{data: %{"content" => content}} = object) do
-    content
+  defp scrub_html_and_truncate_object_field(field, object) do
+    field
     # html content comes from DB already encoded, decode first and scrub after
     |> HtmlEntities.decode()
     |> String.replace(~r/<br\s?\/?>/, " ")
@@ -20,6 +19,17 @@ defmodule Pleroma.Web.Metadata.Utils do
     |> Formatter.truncate()
   end
 
+  def scrub_html_and_truncate(%{data: %{"summary" => summary}} = object)
+      when is_binary(summary) and summary != "" do
+    summary
+    |> scrub_html_and_truncate_object_field(object)
+  end
+
+  def scrub_html_and_truncate(%{data: %{"content" => content}} = object) do
+    content
+    |> scrub_html_and_truncate_object_field(object)
+  end
+
   def scrub_html_and_truncate(content, max_length \\ 200) when is_binary(content) do
     content
     |> scrub_html
@@ -38,10 +48,6 @@ defmodule Pleroma.Web.Metadata.Utils do
 
   def scrub_html(content), do: content
 
-  def attachment_url(url) do
-    MediaProxy.preview_url(url)
-  end
-
   def user_name_string(user) do
     "#{user.name} " <>
       if user.local do