retrospring/app/models/appendable/reaction.rb
2022-07-05 23:23:37 +02:00

21 lines
564 B
Ruby

# frozen_string_literal: true
class Appendable::Reaction < Appendable
# 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 unless parent.user == user
user.decrement! :smiled_count
parent.decrement! :smile_count
end
# rubocop:enable Rails/SkipsModelValidations
def notification_type(*_args)
Notifications::Smiled
end
end