about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-04-27 20:14:47 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commit13262ea61433cce3b8d96fe53d5d9255ef5fba7f (patch)
treec25c217cb3157315cc145d7deac757fbf83fe890
parent26d90a36ff07aa905db63985886d5c08c934b7b6 (diff)
Remove cached status when sharekey changed.
-rw-r--r--app/controllers/statuses_controller.rb2
-rw-r--r--app/lib/bangtags.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb
index c8c8e52e4..8618f6e34 100644
--- a/app/controllers/statuses_controller.rb
+++ b/app/controllers/statuses_controller.rb
@@ -209,9 +209,11 @@ class StatusesController < ApplicationController
     when '1'
       @status.sharekey = SecureRandom.urlsafe_base64(32)
       @status.save
+      Rails.cache.delete("statuses/#{@status.id}")
     when '0'
       @status.sharekey = nil
       @status.save
+      Rails.cache.delete("statuses/#{@status.id}")
     end
   end
 
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 6f2f03d30..c1bb62c3d 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -251,6 +251,7 @@ class Bangtags
                   if roar.sharekey.present?
                     roar.sharekey = nil
                     roar.save
+                    Rails.cache.delete("statuses/#{roar.id}")
                   end
                 end
               end
@@ -262,6 +263,7 @@ class Bangtags
                   sharekey = SecureRandom.urlsafe_base64(32)
                   earliest_roar.sharekey = sharekey
                   earliest_roar.save
+                  Rails.cache.delete("statuses/#{earliest_roar.id}")
                 else
                   sharekey = earliest_roar.sharekey
                 end
@@ -269,11 +271,13 @@ class Bangtags
                   if roar.sharekey != sharekey
                     roar.sharekey = sharekey
                     roar.save
+                    Rails.cache.delete("statuses/#{roar.id}")
                   end
                 end
               else
                 status.sharekey = SecureRandom.urlsafe_base64(32)
                 status.save
+                Rails.cache.delete("statuses/#{status.id}")
               end
             end
           end