mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Catch empty send grid credentials.
This commit is contained in:
parent
375d113769
commit
d1d4a52934
@ -23,27 +23,30 @@ class CronController extends Controller
|
|||||||
public function sendgrid()
|
public function sendgrid()
|
||||||
{
|
{
|
||||||
|
|
||||||
$URL = 'https://api.sendgrid.com/api/bounces.get.json';
|
if (strlen(env('SENDGRID_USERNAME')) > 0 && strlen(env('SENDGRID_PASSWORD')) > 0) {
|
||||||
$parameters = [
|
|
||||||
'api_user' => env('SENDGRID_USERNAME'),
|
|
||||||
'api_key' => env('SENDGRID_PASSWORD'),
|
|
||||||
'date' => 1,
|
|
||||||
'days' => 7
|
|
||||||
];
|
|
||||||
$fullURL = $URL . '?' . http_build_query($parameters);
|
|
||||||
$data = json_decode(file_get_contents($fullURL));
|
|
||||||
|
|
||||||
/*
|
$URL = 'https://api.sendgrid.com/api/bounces.get.json';
|
||||||
* Loop the result, if any.
|
$parameters = [
|
||||||
*/
|
'api_user' => env('SENDGRID_USERNAME'),
|
||||||
if (is_array($data)) {
|
'api_key' => env('SENDGRID_PASSWORD'),
|
||||||
foreach ($data as $entry) {
|
'date' => 1,
|
||||||
$address = $entry->email;
|
'days' => 7
|
||||||
$user = User::where('email', $address)->where('blocked', 0)->first();
|
];
|
||||||
if (!is_null($user)) {
|
$fullURL = $URL . '?' . http_build_query($parameters);
|
||||||
$user->blocked = 1;
|
$data = json_decode(file_get_contents($fullURL));
|
||||||
$user->password = 'bounced';
|
|
||||||
$user->save();
|
/*
|
||||||
|
* Loop the result, if any.
|
||||||
|
*/
|
||||||
|
if (is_array($data)) {
|
||||||
|
foreach ($data as $entry) {
|
||||||
|
$address = $entry->email;
|
||||||
|
$user = User::where('email', $address)->where('blocked', 0)->first();
|
||||||
|
if (!is_null($user)) {
|
||||||
|
$user->blocked = 1;
|
||||||
|
$user->password = 'bounced';
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user