argument('group'); $type = (int) $this->argument('type'); $quantity = $this->argument('quantity'); if (! \in_array($type, [1, 2], true)) { $this->error('Invalid backfill type. Must be 1 (interval) or 2 (all).'); return self::FAILURE; } try { $nntp = $this->getNntp(); if ($quantity === null) { $value = Settings::settingValue('backfill_qty'); $quantity = ($type === 1 ? '' : $value); } $this->info("Backfilling group: {$group}"); (new BackfillService(nntp: $nntp))->backfillAllGroups($group, $quantity); return self::SUCCESS; } catch (\Throwable $e) { Log::error($e->getTraceAsString()); $this->error($e->getMessage()); return self::FAILURE; } } /** * Get NNTP connection. */ private function getNntp(): NNTPService { $nntp = new NNTPService; $connectResult = config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect(false, true) : $nntp->doConnect(); if ($connectResult !== true) { $errorMessage = 'Unable to connect to usenet.'; if (NNTPService::isError($connectResult)) { $errorMessage .= ' Error: '.$connectResult->getMessage(); } throw new \Exception($errorMessage); } return $nntp; } }