You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
namespace Isekai\UserPoints\Quests\Api;
|
|
|
|
use ApiBase;
|
|
use Isekai\UserPoints\Quests\QuestsUtils;
|
|
use MediaWiki\Session\SessionManager;
|
|
|
|
class ApiUserQuestsGetNotification extends ApiBase {
|
|
public function __construct( $main, $method ) {
|
|
parent::__construct( $main->getMain(), $method );
|
|
}
|
|
|
|
public function execute() {
|
|
$user = $this->getUser();
|
|
|
|
if (!$user->isRegistered()) {
|
|
$this->dieWithError('apierror-mustbeloggedin-generic', 'login-required');
|
|
}
|
|
|
|
$sessionManager = SessionManager::getGlobalSession();
|
|
if ($sessionManager->exists(QuestsUtils::SESSION_KEY_QUEST_COMPLETE_NOTIFICATION)) {
|
|
$notificationData = $sessionManager->get(QuestsUtils::SESSION_KEY_QUEST_COMPLETE_NOTIFICATION);
|
|
$this->getResult()->addValue(['userquestsgetnotification'], 'notification', $notificationData);
|
|
$sessionManager->remove(QuestsUtils::SESSION_KEY_QUEST_COMPLETE_NOTIFICATION);
|
|
} else {
|
|
$this->getResult()->addValue(['userquestsgetnotification'], 'notification', null);
|
|
}
|
|
}
|
|
|
|
public function isInternal() {
|
|
return true;
|
|
}
|
|
} |