finally made that worker work.
This commit is contained in:
parent
02cb318142
commit
e789fb7e68
|
@ -46,14 +46,8 @@ class Ajax::InboxController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
# sharing
|
||||
begin
|
||||
share_to = JSON.parse params[:share]
|
||||
current_user.services.each do |service|
|
||||
service.post(answer) if share_to.include? service.provider
|
||||
end
|
||||
rescue
|
||||
end
|
||||
services = JSON.parse params[:share]
|
||||
ShareWorker.perform_async(current_user.id, answer.id, services)
|
||||
|
||||
@status = :okay
|
||||
@message = "Successfully answered question."
|
||||
|
|
|
@ -3,7 +3,16 @@ class ShareWorker
|
|||
|
||||
sidekiq_options queue: :share
|
||||
|
||||
def perform(answer_id)
|
||||
# fuck this… for now
|
||||
# @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
|
||||
Rails.logger.error "failed to post answer #{answer_id} to #{service.provider} for user #{user_id}: #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue