/** * @param \Seat\Web\Validation\ApiKey $request * @param \Seat\Eveapi\Helpers\JobContainer $job * * @return \Illuminate\Http\RedirectResponse */ public function addKey(ApiKey $request, JobContainer $job) { ApiKeyModel::create(['key_id' => $request->input('key_id'), 'v_code' => $request->input('v_code'), 'user_id' => auth()->user()->id, 'enabled' => true]); // Get a fresh instance of the API Key $api_key = ApiKeyModel::find($request->input('key_id')); $job->scope = 'Key'; $job->api = 'Scheduler'; $job->owner_id = $request->input('key_id'); $job->eve_api_key = $api_key; // Queue the update Job $job_id = $this->addUniqueJob(CheckAndQueueKey::class, $job); return redirect()->route('api.key')->with('success', trans('web::seat.add_success', ['jobid' => $job_id])); }
/** * Load worker classes from the configuration * file based on the 'api' type in the * job tracker. This method honors the class * definitions in eveapi.config.disabled_workers * as well as the key specific disabled_workers. * * @param \Seat\Eveapi\Models\JobTracking $job * * @return mixed */ public function load_workers(JobTracking $job) { $type = strtolower($job->api); $workers = config('eveapi.workers.' . $type); $global_disabled_workers = config('eveapi.config.disabled_workers.' . $type); $key_disabled_workers = $job->owner_id == 0 ? [] : json_decode(ApiKey::find($job->owner_id)->disabled_calls); // Check that we do not have a null result // for the key specific disabled workers if (is_null($key_disabled_workers)) { $key_disabled_workers = []; } // Check if any workers are ignored either via // the global config or this specific key. foreach ($workers as $worker) { if (in_array($worker, array_merge($global_disabled_workers, $key_disabled_workers))) { // Remove the worker. $workers = array_diff($workers, [$worker]); } } return $workers; }