|
|
|
@ -3,7 +3,9 @@ namespace Isekai\AIToolbox\Job;
|
|
|
|
|
|
|
|
|
|
use Job;
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
use Title;
|
|
|
|
|
use MediaWiki\Context\RequestContext;
|
|
|
|
|
use MediaWiki\Title\Title;
|
|
|
|
|
use MediaWiki\Status\Status;
|
|
|
|
|
|
|
|
|
|
class UpdateTitleIndexJob extends Job {
|
|
|
|
|
public function __construct(Title $title) {
|
|
|
|
@ -16,6 +18,7 @@ class UpdateTitleIndexJob extends Job {
|
|
|
|
|
public function run() {
|
|
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
$context = RequestContext::getMain();
|
|
|
|
|
|
|
|
|
|
$endpoint = $config->get('IsekaiAIBackendEndpoint');
|
|
|
|
|
$authToken = $config->get('IsekaiAIToolboxToken');
|
|
|
|
@ -34,9 +37,11 @@ class UpdateTitleIndexJob extends Job {
|
|
|
|
|
|
|
|
|
|
$req->setHeader('Authorization', 'Bearer ' . $authToken);
|
|
|
|
|
|
|
|
|
|
$status = \Status::wrap($req->execute());
|
|
|
|
|
$status = Status::wrap($req->execute());
|
|
|
|
|
if (!$status->isOK()) {
|
|
|
|
|
$this->setLastError($status->getMessage());
|
|
|
|
|
$formatterFactory = MediaWikiServices::getInstance()->getFormatterFactory();
|
|
|
|
|
$formatter = $formatterFactory->getStatusFormatter($context);
|
|
|
|
|
$this->setLastError($formatter->getMessage($status));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|