1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Refresh gmail tokens prior to emailing events

This commit is contained in:
David Bomba 2021-06-23 08:31:22 +10:00
parent d1d0945089
commit 83b798dba0

View File

@ -178,7 +178,14 @@ class NinjaMailerJob implements ShouldQueue
$google = (new Google())->init();
try{
if ($google->getClient()->isAccessTokenExpired()) {
$google->refreshToken($user);
$user = $user->fresh();
}
$google->getClient()->setAccessToken(json_encode($user->oauth_user_token));
}
catch(\Exception $e) {
$this->logMailError('Gmail Token Invalid', $this->company->clients()->first());
@ -186,9 +193,7 @@ class NinjaMailerJob implements ShouldQueue
return $this->setMailDriver();
}
if ($google->getClient()->isAccessTokenExpired()) {
$google->refreshToken($user);
}
/*
* Now that our token is refreshed and valid we can boot the