about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-16 22:09:29 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-16 22:09:29 -0600
commita5335d8baeffcfe8bcdb8e41f7908644b19d667f (patch)
tree295d481b8f06322b816c2c4fb300ecf8adc016f6 /app
parente02073f7daa5f374d158d2b0636f5edc5cec823f (diff)
Allow callers of `Formatter` methods to specify that formatting results should not be cached.
Diffstat (limited to 'app')
-rw-r--r--app/lib/formatter.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index c190e193c..252532dc0 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -215,7 +215,7 @@ class Formatter
     unless status.local?
       html = reformat(raw_content)
 
-      Rails.cache.write("formatted_status:#{orig_status.id}", html, expires_in: CACHE_TIME)
+      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
@@ -256,7 +256,7 @@ 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)
+    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
@@ -318,7 +318,7 @@ class Formatter
       html = reformat(account.note)
     end
 
-    Rails.cache.write("formatted_account:#{account.id}", html, expires_in: CACHE_TIME)
+    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
@@ -339,7 +339,7 @@ class Formatter
 
     html = encode(status.spoiler_text)
 
-    Rails.cache.write("formatted_spoiler:#{status.id}", html, expires_in: CACHE_TIME)
+    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
@@ -356,7 +356,7 @@ class Formatter
 
     html = encode(option.title)
 
-    Rails.cache.write("formatted_poll:#{status.id}:#{option.id}", html, expires_in: CACHE_TIME)
+    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
@@ -373,7 +373,7 @@ class Formatter
 
     html = encode(account.display_name.presence || account.username)
 
-    Rails.cache.write("formatted_display_name:#{account.id}", html, expires_in: CACHE_TIME)
+    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