fixes #2892: after_destroy callbacks should be fired upon comment deletion

This commit is contained in:
r888888888
2017-02-27 16:43:19 -08:00
parent a90a1bd895
commit b332273378

View File

@@ -14,8 +14,8 @@ class Comment < ActiveRecord::Base
after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec| after_update(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec|
ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}") ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}")
end end
after_destroy :update_last_commented_at_on_destroy after_update :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed?}
after_destroy(:if => lambda {|rec| CurrentUser.id != rec.creator_id}) do |rec| after_update(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}") ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
end end
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin] attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]