Пример #1
1
 /**
  * @param callable $callback A task to start processing in the background
  * @return Task
  */
 public function async(callable $callback) : Task
 {
     $id = TaskIdFactory::new();
     $task = new Task($this->subscriber, $id);
     $this->queue->push($id, $callback);
     return $task;
 }
Пример #2
0
 /**
  * Tests deprovision request
  */
 public function testDeprovision()
 {
     $_instanceId = 'wicker';
     $_payload = ['instance-id' => $_instanceId, 'owner-id' => 22, 'guest-location' => GuestLocations::DFE_CLUSTER];
     $_job = new DeprovisionJob($_instanceId, $_payload);
     $_result = \Queue::push($_job);
 }
Пример #3
0
 public function postLogin(Request $request)
 {
     $this->validate($request, ['user_id' => 'required', 'password' => 'required']);
     $credentials = $request->only('user_id', 'password');
     $redirect = $this->redirectPath();
     $lock_new_users = true;
     $try = false;
     if (User::find($credentials['user_id'])) {
         // The user exists
         $try = true;
     } else {
         if ($lock_new_users) {
             return redirect('/locked');
         } else {
             if (($person = Person::find($credentials['user_id'])) && DataSource::check_login($credentials['user_id'], $credentials['password'])) {
                 // The ID exists and details are correct, but there isn't an account for it. Make one.
                 $user = User::create(['user_id' => $credentials['user_id'], 'name' => $person->name, 'password' => \Crypt::encrypt($credentials['password']), 'is_queued' => true]);
                 \Queue::push(new PrepareUser($user));
                 $redirect = '/setup';
                 $try = true;
             }
         }
     }
     if ($try && Auth::attempt($credentials, $request->has('remember'))) {
         return redirect()->intended($redirect);
     }
     return redirect($this->loginPath())->withInput($request->only('user_id', 'remember'))->withErrors(['user_id' => $this->getFailedLoginMessage()]);
 }
Пример #4
0
 public function deletePicture()
 {
     if (Input::has('keys')) {
         Queue::push('qiniu_delete', Input::get('keys'));
     }
     return Response::make('');
 }
Пример #5
0
 /**
  * @param int        $campaignId
  * @param int        $startTime
  * @param int        $startId
  * @param int        $endId
  * @param null|array $additionalData
  *
  * @return bool
  * @throws \Exception
  */
 public static function pushCampaign($campaignId, $startTime = null, $startId = null, $endId = null, $additionalData = null)
 {
     if ($startTime === null) {
         $startTime = time();
         $startTime -= $startTime % 60;
     }
     $campaign = new Campaign($campaignId);
     $campaign->reload();
     if (!$campaign->processors) {
         throw new \Exception('Cannot queue a Campaign with no Processors');
     }
     $lastTime = $campaign->lastSent;
     if ($lastTime != $startTime) {
         $campaign->lastSent = $startTime;
         $campaign->saveChanges();
         $message = new ProcessMessage();
         $message->setData('campaignId', $campaignId);
         $message->setData('startedAt', $startTime);
         $message->setData('lastSent', $lastTime);
         $message->setData('startId', $startId);
         $message->setData('endId', $endId);
         if ($additionalData) {
             $message->setData('additionalData', $additionalData);
         }
         \Queue::setDefaultQueueProvider("campaignqueue");
         \Queue::push(new StdQueue('defero_campaigns'), serialize($message));
         \Log::info('Queued Campaign ' . $campaignId);
         return true;
     }
     \Log::info('Campaign ' . $campaignId . ' already queued' . ' ~ ' . $lastTime . ' ' . $startTime);
     return false;
 }
Пример #6
0
 public function fire()
 {
     $hosts = Host::where('state', '!=', 'disabled')->where('cron', '=', 'yes')->get(array('id'));
     foreach ($hosts as $host) {
         Queue::push('BackupController@dailyBackup', array('id' => $host->id));
     }
 }
 public function put($uid)
 {
     $token = Input::get('token');
     $result = $this->contextIO->getConnectToken(null, $token);
     if (!$result) {
         return ['success' => 'false', 'error_message' => 'Failed to retrieve a connect token from context.io'];
     }
     $response = $result->getData();
     $responseJSON = json_encode($response);
     $response = json_decode($responseJSON);
     $data = $response->account;
     $serviceMap = ['imap.googlemail.com' => 'gmail', 'imap-mail.outlook.com:993' => 'outlook'];
     $desired_data = ['email_address' => $data->email_addresses[0], 'mailbox_id' => $data->id, 'service' => isset($serviceMap[$data->sources[0]->server]) ? $serviceMap[$data->sources[0]->server] : 'other'];
     $account = new Mailbox();
     $account->id = $uid;
     $account->mailbox_id = $desired_data['mailbox_id'];
     $account->email_address = $desired_data['email_address'];
     $account->service = $desired_data['service'];
     if (!$account->save()) {
         return ['success' => false, 'error_message' => 'Failed to save account details'];
     }
     // TODO: Start sync process
     // Queue Mailbox crawl
     try {
         Queue::push('ContextIOCrawlerController@dequeue', ['id' => $uid], 'contextio.sync.' . Config::get('queue.postfix'));
     } catch (Exception $e) {
         return ['success' => false, 'error_message' => $e->getMessage()];
     }
     return ['success' => true];
 }
 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Code - ' . $this->site_name;
     $input = Input::only('code', 'launcher', 'modpack');
     $modpackcode = ModpackCode::find($id);
     $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!'];
     $validator = Validator::make($input, ['code' => 'required|unique:modpack_codes,code,' . $modpackcode->id, 'launcher' => 'required', 'modpack' => 'required'], $messages);
     if ($validator->fails()) {
         // TODO this line originally redirects to modpack-code/edit, there's no route for this, is this an error?
         return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $modpackcode->code = $input['code'];
     $modpackcode->modpack_id = $input['modpack'];
     $modpackcode->launcher_id = $input['launcher'];
     $modpackcode->last_ip = Request::getClientIp();
     $success = $modpackcode->save();
     if ($success) {
         Cache::tags('modpacks')->flush();
         Queue::push('BuildCache');
         return View::make('modpackcodes.edit', ['title' => $title, 'success' => true, 'modpackcode' => $modpackcode]);
     }
     return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors(['message' => 'Unable to add modpack code.'])->withInput();
 }
Пример #9
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // message
     $data = array('type' => $this->argument('type'), 'id' => $this->argument('id'), 'date' => $this->argument('date'));
     // add message to queue
     Queue::push("Scraper", $data);
 }
Пример #10
0
 public static function addToQueue($queue, $ownerID, $vCode, $api, $scope)
 {
     // Prepare the auth array
     if ($vCode != null) {
         $auth = array('keyID' => $ownerID, 'vCode' => $vCode);
     } else {
         $auth = array();
     }
     // Check the databse if there are jobs outstanding ie. they have the status
     // Queued or Working. If not, we will queue a new job, else just capture the
     // jobID and return that
     $jobID = \SeatQueueInformation::where('ownerID', '=', $ownerID)->where('api', '=', $api)->whereIn('status', array('Queued', 'Working'))->first();
     // Check if the $jobID was found, else, queue a new job
     if (!$jobID) {
         $jobID = \Queue::push($queue, $auth);
         \SeatQueueInformation::create(array('jobID' => $jobID, 'ownerID' => $ownerID, 'api' => $api, 'scope' => $scope, 'status' => 'Queued'));
     } else {
         // To aid in potential capacity debugging, lets write a warning log entry so that a user
         // is able to see that a new job was not submitted
         \Log::warning('A new job was not submitted due a similar one still being outstanding. Details: ' . $jobID, array('src' => __CLASS__));
         // Set the jobID to the ID from the database
         $jobID = $jobID->jobID;
     }
     return $jobID;
 }
Пример #11
0
 function show(Pilot $pilot)
 {
     $active = Flight::with('departure', 'departure.country', 'arrival', 'arrival.country')->whereVatsimId($pilot->vatsim_id)->whereIn('state', array(0, 1, 3, 4))->first();
     $flights = Flight::with('departure', 'departure.country', 'arrival', 'arrival.country')->whereVatsimId($pilot->vatsim_id)->whereState(2)->orderBy('arrival_time', 'desc')->take(15)->get();
     $flightCount = Flight::whereVatsimId($pilot->vatsim_id)->whereState(2)->count();
     $stats = new FlightStat(Flight::whereVatsimId($pilot->vatsim_id));
     if ($pilot->processing == 0) {
         Queue::push('LegacyUpdate', $pilot->vatsim_id, 'legacy');
         $pilot->processing = 2;
         $pilot->save();
     }
     if ($pilot->processing == 2) {
         Messages::success('The data for this pilot is currently being processed. In a couple of minutes, all statistics will be available.')->one();
     }
     $distances = $stats->distances($pilot->distance);
     $citypair = $stats->citypair();
     if ($flights->count() > 0) {
         $durations = $stats->durations($pilot->duration);
         extract($durations);
     }
     // Charts: popular airlines, airports and aircraft
     $airlines = $stats->topAirlines();
     $airports = $stats->topAirports();
     $aircraft = $stats->topAircraft();
     $this->javascript('assets/javascript/jquery.flot.min.js');
     $this->javascript('assets/javascript/jquery.flot.pie.min.js');
     $this->autoRender(compact('pilot', 'flights', 'active', 'distances', 'airlines', 'aircraft', 'airports', 'longest', 'shortest', 'citypair', 'hours', 'minutes'), $pilot->name);
 }
 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Code - ' . $this->site_name;
     $input = Input::only('name', 'deck', 'description', 'slug');
     $modpacktag = ModpackTag::find($id);
     $messages = ['unique' => 'This modpack tag already exists in the database!'];
     $validator = Validator::make($input, ['name' => 'required|unique:modpack_tags,name,' . $modpacktag->id, 'deck' => 'required'], $messages);
     if ($validator->fails()) {
         return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $modpacktag->name = $input['name'];
     $modpacktag->deck = $input['deck'];
     $modpacktag->description = $input['description'];
     $modpacktag->last_ip = Request::getClientIp();
     if ($input['slug'] == '' || $input['slug'] == $modpacktag->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $modpacktag->slug = $slug;
     $success = $modpacktag->save();
     if ($success) {
         Cache::tags('modpacks')->flush();
         Queue::push('BuildCache');
         return View::make('tags.modpacks.edit', ['title' => $title, 'success' => true, 'modpacktag' => $modpacktag]);
     }
     return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack code.'])->withInput();
 }
Пример #13
0
 public function placeNodeInLimbo($node_id, $integration_id)
 {
     $node = Node::find($node_id);
     $node->limbo = true;
     Queue::push('DeployAgentToNode', array('message' => array('node_id' => $node_id, 'integration_id' => $integration_id)));
     $node->save();
 }
Пример #14
0
 /**
  * Store a newly created upload in storage.
  *
  * @return Response
  */
 public function store()
 {
     Upload::setRules('store');
     if (!Upload::canCreate()) {
         return $this->_access_denied();
     }
     $file = Input::file('file');
     $hash = md5(microtime() . time());
     $data = [];
     $data['path'] = public_path() . '/uploads/' . $hash . '/';
     mkdir($data['path']);
     $data['url'] = url('uploads/' . $hash);
     $data['name'] = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $file->getClientOriginalName());
     $data['type'] = $file->getMimeType();
     $data['size'] = $file->getSize();
     $data['uploadable_type'] = Request::header('X-Uploader-Class');
     $data['uploadable_id'] = Request::header('X-Uploader-Id') ? Request::header('X-Uploader-Id') : 0;
     $data['token'] = Request::header('X-CSRF-Token');
     $file->move($data['path'], $data['name']);
     if (property_exists($data['uploadable_type'], 'generate_image_thumbnails')) {
         Queue::push('ThumbnailService', array('path' => $data['path'] . '/' . $data['name']));
     }
     $upload = new Upload();
     $upload->fill($data);
     if (!$upload->save()) {
         return $this->_validation_error($upload);
     }
     if (Request::ajax()) {
         return Response::json($upload, 201);
     }
     return Redirect::back()->with('notification:success', $this->created_message);
 }
Пример #15
0
 public function toDBResult()
 {
     foreach ($this->items as $item) {
         $result_id = $item->toDBResult();
         \Queue::push(new \App\Commands\ProcessResult($result_id));
     }
 }
 public function put($uid)
 {
     $this->callbackURL = Input::get('callback');
     $subscription_data = ['code' => Input::get('code'), 'state' => Input::get('state')];
     $authorization_data = [];
     try {
         list($authorization_data['dropbox_access_token'], $authorization_data['dropbox_user_id'], $authorization_data['url_state']) = $this->getWebAuth()->finish($subscription_data);
     } catch (Dropbox\Exception_BadRequest $e) {
         return ['success' => false, 'error_message' => $e->getMessage()];
     }
     assert($authorization_data['url_state'] === null);
     // Store this as a new Dropbox
     try {
         $dropbox = new Dropbox();
         $dropbox->id = $uid;
         $dropbox->dropbox_authorized_id = $authorization_data['dropbox_user_id'];
         $dropbox->dropbox_token = $authorization_data['dropbox_access_token'];
         $dropbox->save();
     } catch (Illuminate\Database\QueryException $e) {
         return ['success' => false, 'error_message' => $e->getMessage()];
     }
     // Queue Dropbox crawl
     try {
         Queue::push('DropboxCrawlerController@dequeue', ['id' => $dropbox->id], $this->sync_queue_id);
     } catch (Exception $e) {
         return ['success' => false, 'error_message' => $e->getMessage()];
     }
     return ['success' => true];
 }
Пример #17
0
 public function saveRegisterInfo()
 {
     if (!$this->user->isValid(Input::all())) {
         // redirect our user back to the form with the errors from the validator
         return Redirect::back()->withInput()->withErrors($this->user->errors);
     } else {
         $shareOnLinkedin = '';
         if (!empty(Input::get('shareOnLinkedin'))) {
             $shareOnLinkedin = Input::get('shareOnLinkedin');
         }
         $id = Auth::User()->id;
         $termsofuse = Auth::User()->termsofuse;
         $userstatus = Auth::User()->userstatus;
         $linkedinid = Auth::User()->linkedinid;
         $fname = Input::get('fname');
         $lname = Input::get('lname');
         if (!empty($fname)) {
             $connection = Connection::where('networkid', '=', $linkedinid)->first();
             $connection->fname = strip_tags($fname);
             $connection->lname = strip_tags($lname);
             $connection->save();
         }
         $user = $this->user->find($id);
         if (!empty($fname)) {
             $user->fname = strip_tags($fname);
             $user->lname = strip_tags($lname);
         }
         $user->causesupported = strip_tags(Input::get('causesupported'));
         $user->urlcause = strip_tags(Input::get('urlcause'));
         $user->donationtypeforcause = strip_tags(Input::get('donationtypeforcause'));
         $user->noofmeetingspm = 2;
         //$user->comments = strip_tags(Input::get('comments'));
         if ($shareOnLinkedin == '1') {
             Queue::push('MessageSender@shareNewRegisterOnLinkedin', array('type' => '9', 'id' => $id));
         }
         //die($termsofuse);
         if ($termsofuse != '1') {
             $user->termsofuse = '1';
             $user->userstatus = 'ready for approval';
             /* // CURL request to update newly registered user on EMAIL TOOL
             			$ch = curl_init(); //create curl resource
             			curl_setopt($ch, CURLOPT_URL, "http://54.200.33.219/add_user/".$user->email);  
             			curl_setopt($ch, CURLOPT_HEADER, 0);
             			curl_exec($ch); // pass url in browser 
             			curl_close($ch); // close curl */
         }
         if ($user->save()) {
             $usergroup = new Usersgroup();
             $usergroup->user_id = $id;
             $usergroup->group_id = '1';
             $usergroup->save();
         }
         if ($termsofuse == '1') {
             return Redirect::to('profile/' . strtolower(Auth::User()->fname . '-' . Auth::User()->lname) . '/' . $id);
         } else {
             return Redirect::to('/dashboard');
         }
     }
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     \Queue::push(function ($job) {
         \Log::info(config('app.test'));
         $job->delete();
     });
     return $this->view('admin');
 }
Пример #19
0
 public function index($ads_id = '')
 {
     $data['id'] = $ads_id;
     $data['username'] = \Request::server('PHP_AUTH_USER');
     \Queue::push('App\\Jobs\\UpdateAdsClickCount', $data);
     $ads = Advertisement::find($ads_id);
     return redirect()->away($ads->url);
 }
Пример #20
0
 public static function boot()
 {
     parent::boot();
     // Setup event bindings...
     Alert::created(function ($alert) {
         \Queue::push(new AlertQueue($alert->id));
     });
 }
 public function flush()
 {
     if (!empty($this->pending_flush)) {
         foreach ($this->pending_flush as $job) {
             \Queue::push('Giftertipster\\Service\\JobHandler\\IndexProduct\\IndexProductInterface', ['fields' => $job['fields']], $job['queue_tube']);
         }
     }
 }
 public function queue()
 {
     \Queue::push(function ($job) {
         //sleep(60);
         \Log::info('Socket');
         $job->delete();
         $this->client->send(json_encode(["channel" => 'toast', 'id' => 2, 'message' => 'System message for user 2']));
     });
 }
Пример #23
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($inbound) {
         Pusherer::trigger('boom', 'add_inbound', $inbound);
         Queue::getIron()->addSubscriber('moCallback', array('url' => url('queue/receive')));
         Queue::push('Inbound@moCallback', $inbound->id, 'moCallback');
     });
 }
Пример #24
0
 /**
  * Push a task to the queue list
  *
  * @throws \Exception if Api methods is not callable
  */
 public static function push()
 {
     $param = func_get_args();
     $method = $param[0];
     if (!method_exists(get_class(), $method)) {
         throw new \Exception('Api method ' . $method . ' is not callable');
     }
     unset($param[0]);
     \Queue::push('Api@fire', array('@method' => $method) + $param);
 }
Пример #25
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->count = Image::count();
     Image::chunk(200, function ($images) {
         foreach ($images as $image) {
             $this->line("Added to queue {$image->id}");
             Queue::push('ImagesResizeQueue', $image);
         }
     });
 }
 /**
  * @param UserHasRegistered $event
  */
 public function whenUserHasRegistered(UserHasRegistered $event)
 {
     \Queue::push(function ($job) use($event) {
         \Mail::send('emails.user.new_user_was_registered', compact('event'), function ($message) use($event) {
             $subject = 'A new account has been registered for you';
             $message->to($event->user->email, $event->user->name)->subject($subject)->from('admin@' . \Config::get('app.domain'), 'Site Admin');
         });
         $job->delete();
     });
 }
Пример #27
0
 public function pushToQueue(array $condition)
 {
     $config = config("es_config");
     $data = array('user_id' => '', 'action' => '', 'object' => '', 'object_id' => '', 'param' => '', 'ip' => \Request::getClientIp(), 'timestamp' => Carbon::now()->timestamp);
     if (isset($condition) && !empty($condition)) {
         $data = array_merge($data, $condition);
     }
     $settings = array('index' => 'dm-' . Carbon::now()->year . '.' . Carbon::now()->month, 'type' => 'user', 'body' => $data);
     \Queue::push($config["path"], $settings);
 }
 /**
  * Send data to storage
  *
  * @param array $requestData
  * @return type
  */
 protected function send($requestData)
 {
     try {
         \Queue::push('Understand\\UnderstandLaravel\\Handlers\\LaravelQueueListener@listen', ['requestData' => $requestData]);
     } catch (\Exception $ex) {
         if (!$this->silent) {
             throw new $ex();
         }
     }
 }
Пример #29
0
 private function dispatchScrapeCatalogJob($subject, $row)
 {
     $column = $row->childNodes->item(0);
     $info = $column->childNodes->item(2)->childNodes->item(0)->attributes->getNamedItem('name')->textContent;
     $split = explode(' ', $info);
     if (Course::find(implode('', explode(' ', $info))) == null && in_array($info[strlen($info) - 1], ['H', 'X'])) {
         return;
     }
     \Queue::push('Courses\\Jobs\\Scraper\\ScrapeCatalog', ['subject' => $subject, 'level' => $split[1]]);
 }
 /**
  * Send data to storage
  *
  * @param mixed $requestData
  * @return type
  */
 protected function send($requestData)
 {
     try {
         \Queue::push('Understand\\UnderstandLaravel5\\Handlers\\LaravelQueueListener@listen', ['requestData' => $requestData]);
     } catch (\Exception $ex) {
         if (!$this->silent) {
             throw new \Understand\UnderstandLaravel5\Exceptions\HandlerException($ex->getMessage(), $ex->getCode(), $ex);
         }
     }
 }