retrospring/app/models/appendable/reaction.rb

22 lines
539 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Appendable::Reaction < Appendable
2022-03-26 18:42:49 +01:00
# rubocop:disable Rails/SkipsModelValidations
after_create do
Notification.notify parent.user, self unless parent.user == user
user.increment! :smiled_count
parent.increment! :smile_count
end
before_destroy do
Notification.denotify parent.user, self
user&.decrement! :smiled_count
parent&.decrement! :smile_count
end
2022-03-26 18:42:49 +01:00
# rubocop:enable Rails/SkipsModelValidations
def notification_type(*_args)
Notifications::Smiled
end
end