Synchronously bust cache after save for comments (#1275)

This commit is contained in:
Andy Zhao 2018-12-07 10:16:46 -05:00 committed by Ben Halpern
parent 86e55c2b6d
commit fbe586497b

View file

@ -20,6 +20,7 @@ class Comment < ApplicationRecord
after_create :after_create_checks
after_save :calculate_score
after_save :bust_cache
after_save :synchronous_bust
before_destroy :before_destroy_actions
after_create :send_email_notification, if: :should_send_email_notification?
after_create :create_first_reaction
@ -292,11 +293,15 @@ class Comment < ApplicationRecord
Comment.comment_async_bust(commentable, user.username)
expire_root_fragment
cache_buster = CacheBuster.new
cache_buster.bust(commentable.path.to_s) if commentable
cache_buster.bust("#{commentable.path}/comments") if commentable
end
handle_asynchronously :bust_cache
def synchronous_bust
cache_buster = CacheBuster.new
cache_buster.bust(commentable.path.to_s) if commentable
end
def send_email_notification
NotifyMailer.new_reply_email(self).deliver
end