about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-16 19:59:05 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:18 -0500
commitf074595602e4efdd307780c942d95bb12afbffe6 (patch)
treef1981de89cbce2a17320f6bf565c1e9f8cd72e22
parentdada6e410f03892e0c787bc93973ce46d2812c87 (diff)
[Formatting] Split remote content formatting to utility method
-rw-r--r--app/lib/formatter.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index dec60a3ea..513b85fc3 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -52,13 +52,7 @@ class Formatter
     end
 
     return '' if raw_content.blank?
-
-    unless status.local?
-      html = reformat(raw_content)
-      html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify]
-      html = format_article_content(summary, html) if options[:article_content] && summary.present?
-      return html.html_safe # rubocop:disable Rails/OutputSafety
-    end
+    return format_remote_content(raw_content, status.emojis, summary: summary, **options) unless status.local?
 
     linkable_accounts = status.active_mentions.map(&:account)
     linkable_accounts << status.account
@@ -80,6 +74,13 @@ class Formatter
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
+  def format_remote_content(html, emojis, **options)
+    html = reformat(html)
+    html = encode_custom_emojis(html, emojis, options[:autoplay]) if options[:custom_emojify]
+    html = format_article_content(options[:summary], html) if options[:article_content] && options[:summary].present?
+    html.html_safe # rubocop:disable Rails/OutputSafety
+  end
+
   def format_markdown(html)
     html = markdown_formatter.render(html)
     html.delete("\r").delete("\n")