Slow down Gmail API requests

This commit is contained in:
David Bomba 2021-10-31 22:21:27 +11:00
parent 8032155b05
commit ae3a5e72eb
2 changed files with 10 additions and 5 deletions

View File

@ -213,12 +213,18 @@ abstract class QueryFilters
public function with_trashed($value) public function with_trashed($value)
{ {
if($value == 'true'){ if($value == 'false'){
$this->builder->withTrashed(); return $this->builder->where('is_deleted', 0);
} }
// if($value == 'true'){
// $this->builder->withTrashed();
// }
return $this->builder; return $this->builder;
} }

View File

@ -212,6 +212,8 @@ class NinjaMailerJob implements ShouldQueue
$google->getClient()->setAccessToken(json_encode($user->oauth_user_token)); $google->getClient()->setAccessToken(json_encode($user->oauth_user_token));
//need to slow down gmail requests otherwise we hit 429's
sleep(1);
} }
catch(\Exception $e) { catch(\Exception $e) {
$this->logMailError('Gmail Token Invalid', $this->company->clients()->first()); $this->logMailError('Gmail Token Invalid', $this->company->clients()->first());
@ -225,9 +227,6 @@ class NinjaMailerJob implements ShouldQueue
* just for this request. * just for this request.
*/ */
// config(['mail.driver' => 'gmail']);
// (new MailServiceProvider(app()))->register();
$token = $user->oauth_user_token->access_token; $token = $user->oauth_user_token->access_token;
$this->nmo $this->nmo