getMain(), $method ); } public function execute() { $services = MediaWikiServices::getInstance(); $user = $this->getUser(); if (!$user->isRegistered()) { $this->dieWithError('apierror-mustbeloggedin-generic', 'login-required'); } /** @var IsekaiUserDailySignFactory */ $dailySignFactory = $services->getService('IsekaiUserDailySign'); $dailySignService = $dailySignFactory->newFromUser($user); $result = $this->getResult(); if (date('Y-m-d') === date('Y-m-d', strtotime($dailySignService->lastSignDate))) { $result->addValue(['userdailysign'], 'success', 0); $result->addValue(['userdailysign'], 'point_delta', []); $this->addWarning('isekai-userpoints-already-signed-today', 'already-signed-today'); return; } $pointDelta = $dailySignService->doSign(); if (!empty($pointDelta)) { $result->addValue(['userdailysign'], 'success', 1); } else { $result->addValue(['userdailysign'], 'success', 0); } $resultPointDelta = []; foreach ($pointDelta as $pointType => $delta) { $pointName = Utils::getPointName($pointType); $pointIcon = Utils::getPointIcon($pointType); $resultPointDelta[] = [ 'point_type' => $pointType, 'name' => $pointName, 'icon' => $pointIcon, 'points' => $delta, ]; } $result->addValue(['userdailysign'], 'point_delta', $resultPointDelta); } public function needsToken() { return 'csrf'; } }