Пример #1
0
 /**
  * Create the necessary thumbnails for the given file
  * @param $savedFile
  */
 private function createThumbnails($savedFile)
 {
     $this->queue->push(function (Job $job) use($savedFile) {
         app('imagy')->createAll($savedFile->path);
         $job->delete();
     });
 }
Пример #2
0
 public function createSyncJob($project)
 {
     if ($project instanceof Project) {
         $project = $project->getName();
     }
     $this->queue->push(SyncProject::class, compact('project'));
 }
 /**
  * Queue a new push notification for sending.
  * 
  * @param AbstractPayload $payload
  * @param array $tokens
  * @param string $queue
  */
 public function queue(Payload $payload, $tokens, $queue = null)
 {
     //Serialize data
     $payload = serialize($payload);
     $tokens = serialize($tokens);
     //Push in queue
     return $this->queue->push('bridge@handleQueuedSending', compact('payload', 'tokens'), $queue);
 }
 /**
  * Upload Pdf to s3 and create contracts
  *
  * @param $key
  */
 public function uploadPdfToS3AndCreateContracts($key)
 {
     $contracts = $this->getJsonData($key);
     foreach ($contracts as $contract) {
         $this->updateContractJsonByID($key, $contract->id, ['create_status' => static::CREATE_PROCESSING], 2);
         try {
             $this->storage->disk('s3')->put($contract->file, $this->filesystem->get($this->getFilePath($key, $contract->file)));
         } catch (Exception $e) {
             $this->logger->error(sprintf('File could not be uploaded : %s', $e->getMessage()));
             continue;
         }
         $data = ['file' => $contract->file, 'filehash' => $contract->filehash, 'user_id' => $contract->user_id, 'metadata' => $contract->metadata];
         try {
             $con = $this->contract->save($data);
             $this->logger->activity('contract.log.save', ['contract' => $con->id], $con->id, $con->user_id);
             $this->updateContractJsonByID($key, $contract->id, ['create_status' => static::CREATE_COMPLETED], 2);
             if ($con) {
                 $this->queue->push('App\\Nrgi\\Services\\Queue\\ProcessDocumentQueue', ['contract_id' => $con->id]);
             }
             $this->logger->info('Contract successfully created.', ['Contract Title' => $con->title]);
         } catch (Exception $e) {
             $this->logger->error($e->getMessage());
             if ($this->storage->disk('s3')->exists($contract->file)) {
                 $this->storage->disk('s3')->delete($contract->file);
             }
             $this->updateContractJsonByID($key, $contract->id, ['create_remarks' => trans('contract.save_fail'), 'create_status' => static::CREATE_FAILED], 2);
         }
         $this->deleteFile($key, $contract->file);
     }
 }
 /**
  * Update Contract status
  *
  * @param $id
  * @param $status
  * @param $type
  * @return bool
  */
 public function updateStatus($id, $status, $type)
 {
     try {
         $contract = $this->contract->findContract($id);
     } catch (ModelNotFoundException $e) {
         $this->logger->error('Contract not found', ['contract id' => $id]);
         return false;
     } catch (Exception $e) {
         $this->logger->error($e->getMessage());
         return false;
     }
     if ($contract->isEditableStatus($status)) {
         $status_key = sprintf('%s_status', $type);
         $old_status = $contract->{$status_key};
         $contract->{$status_key} = $status;
         $contract->save();
         if ($status == Contract::STATUS_PUBLISHED) {
             $this->queue->push('App\\Nrgi\\Services\\Queue\\PostToElasticSearchQueue', ['contract_id' => $id, 'type' => $type], 'elastic_search');
         }
         $this->logger->activity('contract.log.status', ['type' => $type, 'old_status' => $old_status, 'new_status' => $status], $contract->id);
         $this->logger->info("Contract status updated", ['Contract id' => $contract->id, 'Status type' => $type, 'Old status' => $old_status, 'New Status' => $status]);
         return true;
     }
     return false;
 }
Пример #6
0
 /**
  * @param JobDescription $job
  *
  * @return void
  */
 protected function queue(JobDescription $job)
 {
     if ($this->disabled) {
         return;
     }
     if ($job->isDelayed()) {
         return $this->queue->later($job->getDelay(), $job->getClass(), $job->getPayload(), $job->getQueue());
     }
     return $this->queue->push($job->getClass(), $job->getPayload(), $job->getQueue());
 }
 /**
  * @param $annotationStatus
  * @param $contractId
  * @return bool
  */
 public function updateStatus($annotationStatus, $contractId)
 {
     $status = $this->annotation->updateStatus($annotationStatus, $contractId);
     if ($status) {
         if ($annotationStatus == Annotation::PUBLISHED) {
             $this->queue->push('App\\Nrgi\\Services\\Queue\\PostToElasticSearchQueue', ['contract_id' => $contractId, 'type' => 'annotation'], 'elastic_search');
         }
         $this->logger->activity("annotation.status_update", ['status' => $annotationStatus], $contractId);
         $this->logger->info('Annotation status updated.', ['Contract id' => $contractId, 'status' => $annotationStatus]);
     }
     return $status;
 }
Пример #8
0
 /**
  * Push the command onto the given queue instance.
  *
  * @param  \Illuminate\Contracts\Queue\Queue  $queue
  * @param  mixed  $command
  * @return mixed
  */
 protected function pushCommandToQueue($queue, $command)
 {
     if (isset($command->queue, $command->delay)) {
         return $queue->laterOn($command->queue, $command->delay, $command);
     }
     if (isset($command->queue)) {
         return $queue->pushOn($command->queue, $command);
     }
     if (isset($command->delay)) {
         return $queue->later($command->delay, $command);
     }
     return $queue->push('Ahead4\\Bus\\CallQueuedHandler@call', ['pipes' => $this->pipes, 'command' => serialize($command)]);
 }
Пример #9
0
 /**
  * webhook
  *
  * @param $type
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function webhook()
 {
     $headers = ['delivery' => $this->request->header('x-github-delivery'), 'event' => $this->request->header('x-github-event'), 'user-agent' => $this->request->header('user-agent'), 'signature' => $this->request->header('x-hub-signature')];
     $payload = $this->request->all();
     $repo = strtolower($payload['repository']['full_name']);
     foreach ($this->factory->getProjects() as $project) {
         if ($project->config('enable_github_hook', false) === false || $project->config('github_hook_settings.sync.enabled', false) === false) {
             continue;
         }
         $config = $project->config('github_hook_settings');
         $projectRepo = $project->config('github_hook_settings.owner') . '/' . $project->config('github_hook_settings.repository');
         if ($repo !== $projectRepo) {
             continue;
         }
         $hash = hash_hmac('sha1', file_get_contents("php://input"), $project->config('github_hook_settings.sync.webhook_secret'));
         if ($headers['signature'] === "sha1={$hash}") {
             $this->queue->push(\Docit\Hooks\Github\Commands\GithubSyncProject::class, ['project' => $project->getName()]);
             return response('', 200);
         } else {
             return response('Invalid hash', 403);
         }
     }
     return response('', 500);
 }
Пример #10
0
 /**
  * Create new task
  *
  * @param $contract_id
  * @return bool
  */
 public function create($contract_id)
 {
     $contract = $this->contract->findWithPages($contract_id);
     try {
         $this->task->createTasks($contract->pages);
         $this->logger->info('Tasks added in database', ['Contract_id' => $contract_id]);
     } catch (Exception $e) {
         $this->logger->error('createTasks:' . $e->getMessage(), ['Contract_id' => $contract_id]);
         return false;
     }
     try {
         $contract->mturk_status = Contract::MTURK_SENT;
         $contract->save();
     } catch (Exception $e) {
         $this->logger->error('save:' . $e->getMessage(), ['Contract_id' => $contract->id]);
         return false;
     }
     $this->logger->activity('mturk.log.create', ['contract' => $contract->title], $contract->id);
     $this->queue->push('App\\Nrgi\\Mturk\\Services\\Queue\\MTurkQueue', ['contract_id' => $contract->id], 'mturk');
     return true;
 }
Пример #11
0
 /**
  * Push the command onto the given queue instance.
  *
  * @param  \Illuminate\Contracts\Queue\Queue  $queue
  * @param  mixed  $command
  * @return mixed
  */
 protected function pushCommandToQueue($queue, $command)
 {
     if (isset($command->queue, $command->delay)) {
         return $queue->laterOn($command->queue, $command->delay, $command);
     }
     if (isset($command->queue)) {
         return $queue->pushOn($command->queue, $command);
     }
     if (isset($command->delay)) {
         return $queue->later($command->delay, $command);
     }
     return $queue->push($command);
 }
Пример #12
0
 /**
  * Queue a new e-mail message for sending.
  *
  * @param  string|array  $view
  * @param  array  $data
  * @param  \Closure|string  $callback
  * @param  string|null  $queue
  * @return mixed
  */
 public function queue($view, array $data, $callback, $queue = null)
 {
     $callback = $this->buildQueueCallable($callback);
     return $this->queue->push('mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue);
 }
 /**
  * @param DomainMessage $domainMessage
  * @return void
  */
 public function handle(DomainMessage $domainMessage)
 {
     $this->queue->push(QueueToEventDispatcher::class, ['uuid' => (string) $domainMessage->getId(), 'playhead' => $domainMessage->getPlayHead(), 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), 'recorded_on' => (string) $domainMessage->getRecordedOn(), 'type' => $domainMessage->getType()]);
 }
Пример #14
0
 /**
  * Push a new job onto the queue.
  *
  * @param  string $job
  * @param  mixed $data
  * @param  string $queue
  * @return mixed
  */
 public function push($job, $data = '', $queue = null)
 {
     return $this->shortTermQueue->push($job, $data, $queue);
 }
Пример #15
0
 /**
  * @inheritdoc
  */
 public function push($taskId, callable $task)
 {
     $this->illuminateQueue->push(IlluminateQueueHandler::class, [$taskId, $this->serializer->serialize($task)]);
 }
Пример #16
0
 /**
  * Push command to queue.
  *
  * @param \Illuminate\Contracts\Queue\Queue $queue
  * @param \Krucas\Counter\Integration\Laravel\Commands\Base $command
  * @return void
  */
 public function queue(Queue $queue, Base $command)
 {
     if (!is_null($this->queue)) {
         $queue->pushOn($this->queue, $command);
     } else {
         $queue->push($command);
     }
 }
Пример #17
0
 /**
  * Queue a new instance message for sending.
  *
  * @param  \Closure|string $callback
  * @param  string  $queue
  *
  * @return mixed
  */
 public function queue($callback, $queue = null)
 {
     $callback = $this->buildQueueCallable($callback);
     return $this->queue->push('messenger@handleQueuedMessage', compact('callback'), $queue);
 }
Пример #18
0
 /**
  * Queue a new SMS message for sending.
  *
  * @param  array  $data
  * @param  \Closure|string  $callback
  * @param  string|null  $queue
  * @return mixed
  */
 public function queue($recepient, $message, $queue = null)
 {
     $callback = ['recepient' => $recepient, 'message' => $message, 'sender' => isset($sender) ? $sender : null, 'message_type' => isset($message_type) ? $message_type : 0];
     return $this->queue->push('sms@handleQueuedMessage', $callback, $queue);
 }