Retrospring/app/workers/share_worker.rb

19 lines
578 B
Ruby
Raw Normal View History

2014-12-12 14:45:49 -08:00
class ShareWorker
include Sidekiq::Worker
sidekiq_options queue: :share, retry: false
2014-12-12 14:45:49 -08:00
2014-12-27 08:33:49 -08:00
# @param user_id [Integer] the user id
# @param answer_id [Integer] the user id
# @param services [Array] array containing strings
def perform(user_id, answer_id, services)
User.find(user_id).services.each do |service|
begin
service.post(Answer.find(answer_id)) if services.include? service.provider
rescue => e
2015-07-27 00:18:10 -07:00
logger.info "failed to post answer #{answer_id} to #{service.provider} for user #{user_id}: #{e.message}"
2014-12-27 08:33:49 -08:00
end
end
2014-12-12 14:45:49 -08:00
end
end