2022-02-19 17:19:28 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-16 23:42:00 +01:00
|
|
|
class Appendable::Reaction < Appendable
|
2022-03-26 18:42:49 +01:00
|
|
|
# rubocop:disable Rails/SkipsModelValidations
|
2022-02-27 15:43:19 +01:00
|
|
|
after_create do
|
|
|
|
Notification.notify parent.user, self unless parent.user == user
|
|
|
|
user.increment! :smiled_count
|
|
|
|
parent.increment! :smile_count
|
|
|
|
end
|
|
|
|
|
|
|
|
before_destroy do
|
2022-07-06 20:17:37 +02:00
|
|
|
Notification.denotify parent.user, self
|
2022-02-04 22:08:25 +01:00
|
|
|
user&.decrement! :smiled_count
|
|
|
|
parent&.decrement! :smile_count
|
2022-02-27 15:43:19 +01:00
|
|
|
end
|
2022-03-26 18:42:49 +01:00
|
|
|
# rubocop:enable Rails/SkipsModelValidations
|
2022-02-27 15:43:19 +01:00
|
|
|
|
|
|
|
def notification_type(*_args)
|
|
|
|
Notifications::Smiled
|
|
|
|
end
|
2022-02-16 23:42:00 +01:00
|
|
|
end
|