mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 04:16:03 +01:00
finally made that worker work.
This commit is contained in:
parent
02cb318142
commit
e789fb7e68
2 changed files with 13 additions and 10 deletions
|
@ -46,14 +46,8 @@ class Ajax::InboxController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# sharing
|
services = JSON.parse params[:share]
|
||||||
begin
|
ShareWorker.perform_async(current_user.id, answer.id, services)
|
||||||
share_to = JSON.parse params[:share]
|
|
||||||
current_user.services.each do |service|
|
|
||||||
service.post(answer) if share_to.include? service.provider
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
end
|
|
||||||
|
|
||||||
@status = :okay
|
@status = :okay
|
||||||
@message = "Successfully answered question."
|
@message = "Successfully answered question."
|
||||||
|
|
|
@ -3,7 +3,16 @@ class ShareWorker
|
||||||
|
|
||||||
sidekiq_options queue: :share
|
sidekiq_options queue: :share
|
||||||
|
|
||||||
def perform(answer_id)
|
# @param user_id [Integer] the user id
|
||||||
# fuck this… for now
|
# @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
|
||||||
end
|
end
|
Loading…
Reference in a new issue