docbrown/app/services/notification_subscriptions/update.rb
Anna Buianova 784afdf41e
Routine rubocop fixes (#19254)
* Rubocop fixes

* Rubocop fixes

* Fixed rubocop violation

* Fixed policies rubocop violations

* More rubocop fixes
2023-03-24 14:37:44 +03:00

28 lines
587 B
Ruby

module NotificationSubscriptions
class Update
def self.call(...)
new(...).call
end
def initialize(notifiable)
@notifiable = notifiable
end
def call
return unless [Article].include?(notifiable.class)
notification_subscriptions = NotificationSubscription.where(
notifiable_id: notifiable.id,
notifiable_type: notifiable.class.name,
)
return if notification_subscriptions.none?
notification_subscriptions.update_all(user_id: notifiable.user_id)
end
private
attr_reader :notifiable
end
end