From 5d57f3078216bbb40dde1e84f6a6727c8aaf2b54 Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Sun, 16 Jul 2017 15:39:20 +0200 Subject: [PATCH] - fixed "online" status for characters, closed #507 - reduced "afk" wait time until cronjob location check for a character from 5min to 3min --- app/main/cron/characterupdate.php | 7 +++++-- app/main/model/charactermodel.php | 16 ++++++++++++++-- app/pathfinder.ini | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/main/cron/characterupdate.php b/app/main/cron/characterupdate.php index 7ac9ff76..9111464c 100644 --- a/app/main/cron/characterupdate.php +++ b/app/main/cron/characterupdate.php @@ -13,7 +13,10 @@ use Model; class CharacterUpdate { - const CHARACTER_LOG_INACTIVE = 300; + /** + * default character_log time until a log entry get re-checked by cronjob + */ + const CHARACTER_LOG_INACTIVE = 180; /** * max count of "inactive" character log data that will be checked for offline status @@ -31,7 +34,7 @@ class CharacterUpdate { } /** - * delete all character log data that were set to "active = 0" after X seconds of no changes + * delete all character log data that have not changed since X seconds * -> see deactivateLogData() * >> php index.php "/cron/deleteLogData" * @param \Base $f3 diff --git a/app/main/model/charactermodel.php b/app/main/model/charactermodel.php index 88ceb308..cb069fed 100644 --- a/app/main/model/charactermodel.php +++ b/app/main/model/charactermodel.php @@ -632,6 +632,14 @@ class CharacterModel extends BasicModel { return $rolesData; } + /** + * check whether this char has accepted all "basic" api scopes + * @return bool + */ + public function hasBasicScopes(){ + return empty( array_diff(Sso::getScopesByAuthType(), $this->esiScopes) ); + } + /** * check whether this char has accepted all admin api scopes * @return bool @@ -650,8 +658,12 @@ class CharacterModel extends BasicModel { $deleteLog = false; $invalidResponse = false; - //check if log update is enabled for this user - if( $this->logLocation ){ + //check if log update is enabled for this character + // check if character has accepted all scopes. (This fkt is called by cron as well) + if( + $this->logLocation && + $this->hasBasicScopes() + ){ // Try to pull data from API if( $accessToken = $this->getAccessToken() ){ $onlineData = self::getF3()->ccpClient->getCharacterOnlineData($this->_id, $accessToken, $additionalOptions); diff --git a/app/pathfinder.ini b/app/pathfinder.ini index ea009265..1162c185 100644 --- a/app/pathfinder.ini +++ b/app/pathfinder.ini @@ -126,8 +126,8 @@ EXECUTION_LIMIT = 50 ; CACHE =========================================================================================== [PATHFINDER.CACHE] -; delete character log data if if nothing (ship/system/...) for X seconds (seconds) (default: 5min) -CHARACTER_LOG_INACTIVE = 300 +; delete character log data if if nothing (ship/system/...) for X seconds (seconds) (default: 3min) +CHARACTER_LOG_INACTIVE = 180 ; expire time for static system data (seconds) (default: 20d) CONSTELLATION_SYSTEMS = 1728000 ; max expire time. Expired cache files will be deleted by cronjob (seconds) (default: 10d)