Delegate processing of incoming PuSH data to background workers
This commit is contained in:
		
							parent
							
								
									cea28e0c1d
								
							
						
					
					
						commit
						a91c3ef6ce
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
					@ -16,7 +16,7 @@ class Api::SubscriptionsController < ApiController
 | 
				
			||||||
    subscription = @account.subscription(api_subscription_url(@account.id))
 | 
					    subscription = @account.subscription(api_subscription_url(@account.id))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if subscription.verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
 | 
					    if subscription.verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
 | 
				
			||||||
      ProcessFeedService.new.call(body, @account)
 | 
					      ProcessingWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
 | 
				
			||||||
      head 201
 | 
					      head 201
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      head 202
 | 
					      head 202
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										7
									
								
								app/workers/processing_worker.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								app/workers/processing_worker.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					class ProcessingWorker
 | 
				
			||||||
 | 
					  include Sidekiq::Worker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def perform(account_id, body)
 | 
				
			||||||
 | 
					    ProcessFeedService.new.call(body, Account.find(account_id))
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue