about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-18 05:09:18 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-18 05:09:18 -0600
commit59ef948640cb3c6cc268db29ef91a4f3718597e2 (patch)
treed0c634049981b2ef0d6f89221f0937778b0b93eb /app/lib/formatter.rb
parent345c6beb7e8a26e3537506ab3134c509d4ef6dc8 (diff)
Get rid of the `Formatter` cache. It isn't worth the admin headaches.
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb62
1 files changed, 0 insertions, 62 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 252532dc0..bdd372d3e 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -30,8 +30,6 @@ class Formatter
 
   include ActionView::Helpers::TextHelper
 
-  CACHE_TIME = 1.hour
-
 	BBCODE_TAGS = {
     url: {
 			html_open: '<a href="%url%" rel="noopener nofollow" target="_blank">', html_close: '</a>',
@@ -187,16 +185,6 @@ class Formatter
 	}
 
   def format(status, **options)
-    unless options[:skip_cache]
-      html = Rails.cache.fetch("formatted_status:#{status.id}")
-      unless html.nil?
-        html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify]
-        return html.html_safe # rubocop:disable Rails/OutputSafety
-      end
-    end
-
-    orig_status = status
-
     if status.reblog?
       prepend_reblog = status.reblog.account.acct
       status         = status.proper
@@ -214,9 +202,6 @@ class Formatter
 
     unless status.local?
       html = reformat(raw_content)
-
-      Rails.cache.write("formatted_status:#{orig_status.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
       html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify]
       return html.html_safe # rubocop:disable Rails/OutputSafety
     end
@@ -237,7 +222,6 @@ class Formatter
     end
 
     html = format_screenreader(html)
-
     html = encode_and_link_urls(html, linkable_accounts, keep_html: %w(text/markdown text/x-bbcode text/x-bbcode+markdown text/html).include?(status.content_type))
 
     if %w(text/markdown text/x-bbcode text/x-bbcode+markdown text/html).include?(status.content_type)
@@ -256,8 +240,6 @@ class Formatter
       html = "#{html.strip}\n<p class=\"signature\">— #{footer}</p>"
     end
 
-    Rails.cache.write("formatted_status:#{orig_status.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
     html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify]
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
@@ -296,20 +278,11 @@ class Formatter
 
   def plaintext(status)
     return status.text if status.local?
-
     text = status.text.gsub(/(<br \/>|<br>|<\/p>)+/) { |match| "#{match}\n" }
     strip_tags(text)
   end
 
   def simplified_format(account, **options)
-    unless options[:skip_cache]
-      html = Rails.cache.fetch("formatted_account:#{account.id}")
-      unless html.nil?
-        html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if account.local? && options[:custom_emojify]
-        return html.html_safe # rubocop:disable Rails/OutputSafety
-      end
-    end
-
     if account.local?
       html = format_bbdown(account.note)
       html = encode_and_link_urls(html, keep_html: true)
@@ -318,8 +291,6 @@ class Formatter
       html = reformat(account.note)
     end
 
-    Rails.cache.write("formatted_account:#{account.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
     html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if account.local? && options[:custom_emojify]
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
@@ -329,52 +300,19 @@ class Formatter
   end
 
   def format_spoiler(status, **options)
-    unless options[:skip_cache]
-      html = Rails.cache.fetch("formatted_spoiler:#{status.id}")
-      unless html.nil?
-        html = encode_custom_emojis(html, status.emojis, options[:autoplay])
-        return html.html_safe # rubocop:disable Rails/OutputSafety
-      end
-    end
-
     html = encode(status.spoiler_text)
-
-    Rails.cache.write("formatted_spoiler:#{status.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
     html = encode_custom_emojis(html, status.emojis, options[:autoplay])
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   def format_poll_option(status, option, **options)
-    unless options[:skip_cache]
-      html = Rails.cache.fetch("formatted_poll:#{status.id}:#{option.id}")
-      unless html.nil?
-        html = encode_custom_emojis(html, status.emojis, options[:autoplay])
-        return html.html_safe # rubocop:disable Rails/OutputSafety
-      end
-    end
-
     html = encode(option.title)
-
-    Rails.cache.write("formatted_poll:#{status.id}:#{option.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
     html = encode_custom_emojis(html, status.emojis, options[:autoplay])
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   def format_display_name(account, **options)
-    unless options[:skip_cache]
-      html = Rails.cache.fetch("formatted_display_name:#{account.id}")
-      unless html.nil?
-        html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify]
-        return html.html_safe # rubocop:disable Rails/OutputSafety
-      end
-    end
-
     html = encode(account.display_name.presence || account.username)
-
-    Rails.cache.write("formatted_display_name:#{account.id}", html, expires_in: CACHE_TIME) unless options[:cache] == false
-
     html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify]
     html.html_safe # rubocop:disable Rails/OutputSafety
   end