2020-05-25 18:33:09 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-07-27 08:59:56 +02:00
|
|
|
class QuestionWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
|
|
|
sidekiq_options queue: :question, retry: false
|
|
|
|
|
2015-07-27 09:12:12 +02:00
|
|
|
# @param user_id [Integer] user id passed from Devise
|
|
|
|
# @param question_id [Integer] newly created question id
|
2020-05-25 18:33:09 +02:00
|
|
|
def perform(user_id, question_id)
|
|
|
|
user = User.find(user_id)
|
|
|
|
|
|
|
|
user.followers.each do |f|
|
|
|
|
Inbox.create(user_id: f.id, question_id: question_id, new: true)
|
2015-07-27 08:59:56 +02:00
|
|
|
end
|
2020-05-25 18:33:09 +02:00
|
|
|
rescue StandardError => e
|
|
|
|
logger.info "failed to ask question: #{e.message}"
|
2021-12-28 18:32:03 +01:00
|
|
|
Sentry.capture_exception(e)
|
2015-07-27 08:59:56 +02:00
|
|
|
end
|
|
|
|
end
|