docbrown/app/workers/notifications/notifiable_action_worker.rb
Vaidehi Joshi 97678456d6
[15 Min Fix]: Extract a post's followers out of service and onto Article model (#13229)
* Move authors followers out of Notifications::NotifiableAction::Send and into Article model

* Rename authors_followers to followers

* Update followers method in service, oops

* Update app/services/notifications/notifiable_action/send.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-04-07 06:46:32 -07:00

14 lines
476 B
Ruby

module Notifications
class NotifiableActionWorker
include Sidekiq::Worker
sidekiq_options queue: :low_priority, retry: 10
def perform(notifiable_id, notifiable_type, action)
# checking type, but leaving space for notifiable types
return unless notifiable_type == "Article"
notifiable = notifiable_type.constantize.find_by(id: notifiable_id)
Notifications::NotifiableAction::Send.call(notifiable, action) if notifiable
end
end
end