X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/4f1511980043fca288c364b794e540af1c54f95e..656d4fe46b13a1264aa77cac6062646f8ac43ec6:/Command/CalendarCommand.php?ds=sidebyside diff --git a/Command/CalendarCommand.php b/Command/CalendarCommand.php index 25c45ca..a783848 100644 --- a/Command/CalendarCommand.php +++ b/Command/CalendarCommand.php @@ -108,7 +108,7 @@ class CalendarCommand extends Command { //Retrieve cache object //XXX: by default stored in /tmp/symfony-cache/@/W/3/6SEhFfeIW4UMDlAII+Dg //XXX: stored in %kernel.project_dir%/var/cache/airlibre/0/P/IA20X0K4dkMd9-+Ohp9Q - $cache = new FilesystemAdapter($this->config['cache']['namespace'], $this->config['cache']['lifetime'], $this->config['cache']['directory']); + $cache = new FilesystemAdapter($this->config['cache']['namespace'], $this->config['cache']['lifetime'], $this->config['path']['cache']); //Retrieve calendars $cacheCalendars = $cache->getItem('calendars'); @@ -147,10 +147,7 @@ class CalendarCommand extends Command { //With expired token if ($exp = $googleClient->isAccessTokenExpired()) { //Refresh token - if ($googleClient->getRefreshToken()) { - //Retrieve refreshed token - $googleToken = $googleClient->fetchAccessTokenWithRefreshToken($googleClient->getRefreshToken()); - + if (($refreshToken = $googleClient->getRefreshToken()) && ($googleToken = $googleClient->fetchAccessTokenWithRefreshToken($refreshToken)) && empty($googleToken['error'])) { //Add refreshed token $calendars[$clientId]['tokens'][$googleToken['access_token']] = [ 'calendar' => $token['calendar'], @@ -174,7 +171,15 @@ class CalendarCommand extends Command { unset($calendars[$clientId]); } + //Save calendars + $cacheCalendars->set($calendars); + + //Save calendar + $cache->save($cacheCalendars); + //Drop token and report + //XXX: submit app to avoid expiration + //XXX: see https://console.cloud.google.com/apis/credentials/consent?project=calendar-317315 echo 'Token '.$tokenId.' for calendar '.$token['calendar'].' has expired and is not refreshable'."\n"; //Return failure @@ -278,6 +283,7 @@ class CalendarCommand extends Command { foreach($sessions as $sessionId => $session) { //Init shared properties //TODO: validate for constraints here ??? https://developers.google.com/calendar/api/guides/extended-properties + //TODO: drop shared as unused ??? $shared = [ 'gps' => $session['l_latitude'].','.$session['l_longitude'] ]; @@ -289,38 +295,37 @@ class CalendarCommand extends Command { ]; //Init description - #$description = '
'.$session['p_class'].'
'.$session['p_contact'].'
'.$session['p_donate'].'
'.$session['p_link'].'
'.$session['p_profile'].'