receive_local.rb 449 Bytes
Newer Older
Benjamin Neff's avatar
Benjamin Neff committed
1 2
module Workers
  class ReceiveLocal < Base
3
    sidekiq_options queue: :high
Benjamin Neff's avatar
Benjamin Neff committed
4 5 6

    def perform(object_class_string, object_id, recipient_user_ids)
      object = object_class_string.constantize.find(object_id)
Benjamin Neff's avatar
Benjamin Neff committed
7 8 9

      object.receive(recipient_user_ids) if object.respond_to?(:receive)

10
      NotificationService.new.notify(object, recipient_user_ids)
Benjamin Neff's avatar
Benjamin Neff committed
11 12 13 14
    rescue ActiveRecord::RecordNotFound # Already deleted before the job could run
    end
  end
end