public function api_grabjob() { $job = new Job($this->args('job_id')); if (!$job->isHydrated()) { throw new Exception("Job does not exist."); } if (!$job->getQueue()->isMine()) { throw new Exception("This job is not in your queue."); } $bot = new Bot($this->args('bot_id')); if (!$bot->isHydrated()) { throw new Exception("Bot does not exist."); } if (!$bot->isMine()) { throw new Exception("This is not your bot."); } if (!$bot->canGrab($job)) { throw new Exception("You cannot grab this job."); } $bot->grabJob($job); $data = array(); $data['job'] = $job->getAPIData(); $data['bot'] = $bot->getAPIData(); Activity::log($bot->getLink() . " bot grabbed the " . $job->getLink() . " job via the API."); return $data; }
public function api_grabjob() { $job = new Job($this->args('job_id')); if (!$job->isHydrated()) { throw new Exception("Job does not exist."); } if (!$job->getQueue()->isMine()) { throw new Exception("This job is not in your queue."); } $bot = new Bot($this->args('bot_id')); if (!$bot->isHydrated()) { throw new Exception("Bot does not exist."); } if (!$bot->isMine()) { throw new Exception("This is not your bot."); } if (!$bot->canGrab($job)) { throw new Exception("You cannot grab this job."); } //attempt to grab our job. will throw exceptions on failure. $job = $bot->grabJob($job, (bool) $this->args('can_slice')); //okay, do we slice it? if ($job->get('status') == 'slicing' && $this->args('can_slice')) { $job->getSliceJob()->grab($this->args('_uid')); } //return the bot data w/ all our info. $bot = new Bot($bot->id); $data = $bot->getAPIData(); Activity::log($bot->getLink() . " bot grabbed the " . $job->getLink() . " job via the API."); return $data; }