From 41b86307a36c62c037d920b46ee87c3eb3526c50 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Mon, 2 Sep 2019 18:11:02 -0500 Subject: fix that weird `rt` bug --- app/lib/formatter.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 88c502715..2f00a4714 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -30,6 +30,8 @@ class Formatter include ActionView::Helpers::TextHelper + CACHE_TIME = 1.hour + BBCODE_TAGS = { url: { html_open: '', html_close: '', @@ -188,6 +190,8 @@ class Formatter cached = Rails.cache.fetch("formatted_status:#{status.id}") return cached unless cached.nil? + orig_status = status + if status.reblog? prepend_reblog = status.reblog.account.acct status = status.proper @@ -208,7 +212,7 @@ class Formatter html = encode_custom_emojis(html, status.emojis, options[:autoplay]) if options[:custom_emojify] html = html.html_safe # rubocop:disable Rails/OutputSafety - Rails.cache.write("formatted_status:#{status.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_status:#{orig_status.id}", html, expires_in: CACHE_TIME) return html end @@ -254,7 +258,7 @@ class Formatter end html = html.html_safe # rubocop:disable Rails/OutputSafety - Rails.cache.write("formatted_status:#{status.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_status:#{orig_status.id}", html, expires_in: CACHE_TIME) html end @@ -307,7 +311,7 @@ class Formatter html = reformat(account.note) end - Rails.cache.write("formatted_account:#{account.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_account:#{account.id}", html, expires_in: CACHE_TIME) html end @@ -323,7 +327,7 @@ class Formatter html = encode_custom_emojis(html, status.emojis, options[:autoplay]) html = html.html_safe # rubocop:disable Rails/OutputSafety - Rails.cache.write("formatted_spoiler:#{status.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_spoiler:#{status.id}", html, expires_in: CACHE_TIME) html end @@ -335,7 +339,7 @@ class Formatter html = encode_custom_emojis(html, status.emojis, options[:autoplay]) html = html.html_safe # rubocop:disable Rails/OutputSafety - Rails.cache.write("formatted_poll:#{status.id}:#{option.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_poll:#{status.id}:#{option.id}", html, expires_in: CACHE_TIME) html end @@ -347,7 +351,7 @@ class Formatter html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html = html.html_safe # rubocop:disable Rails/OutputSafety - Rails.cache.write("formatted_display_name:#{account.id}", html, expires_in: 30.minutes) + Rails.cache.write("formatted_display_name:#{account.id}", html, expires_in: CACHE_TIME) html end -- cgit