mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix various code.
This commit is contained in:
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Jobs;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
@@ -32,6 +33,11 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Symfony\Component\Mailer\Exception\TransportException;
|
||||
use Exception;
|
||||
|
||||
use function Safe\json_encode;
|
||||
use function Safe\file_put_contents;
|
||||
use function Safe\json_decode;
|
||||
use function Safe\file_get_contents;
|
||||
|
||||
/**
|
||||
* Class MailError.
|
||||
*/
|
||||
@@ -48,7 +54,7 @@ class MailError extends Job implements ShouldQueue
|
||||
$debug = $this->exception;
|
||||
unset($debug['stackTrace'], $debug['headers']);
|
||||
|
||||
app('log')->error(sprintf('Exception is: %s', \Safe\json_encode($debug)));
|
||||
app('log')->error(sprintf('Exception is: %s', json_encode($debug)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,11 +125,11 @@ class MailError extends Job implements ShouldQueue
|
||||
|
||||
if (!file_exists($file)) {
|
||||
Log::debug(sprintf('Wrote new file in "%s"', $file));
|
||||
\Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT));
|
||||
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
|
||||
}
|
||||
if (file_exists($file)) {
|
||||
Log::debug(sprintf('Read file in "%s"', $file));
|
||||
$limits = \Safe\json_decode((string) \Safe\file_get_contents($file), true);
|
||||
$limits = json_decode((string) file_get_contents($file), true);
|
||||
}
|
||||
// limit reached?
|
||||
foreach ($types as $type => $info) {
|
||||
@@ -131,15 +137,15 @@ class MailError extends Job implements ShouldQueue
|
||||
if (!array_key_exists($type, $limits)) {
|
||||
Log::debug(sprintf('Limit "%s" reset to zero, did not exist yet.', $type));
|
||||
$limits[$type] = [
|
||||
'time' => time(),
|
||||
'time' => Carbon::now()->getTimestamp(),
|
||||
'sent' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
if (time() - $limits[$type]['time'] > $info['reset']) {
|
||||
Log::debug(sprintf('Time past for this limit is %d seconds, exceeding %d seconds. Reset to zero.', time() - $limits[$type]['time'], $info['reset']));
|
||||
if (Carbon::now()->getTimestamp() - $limits[$type]['time'] > $info['reset']) {
|
||||
Log::debug(sprintf('Time past for this limit is %d seconds, exceeding %d seconds. Reset to zero.', Carbon::now()->getTimestamp() - $limits[$type]['time'], $info['reset']));
|
||||
$limits[$type] = [
|
||||
'time' => time(),
|
||||
'time' => Carbon::now()->getTimestamp(),
|
||||
'sent' => 0,
|
||||
];
|
||||
}
|
||||
@@ -151,7 +157,7 @@ class MailError extends Job implements ShouldQueue
|
||||
}
|
||||
++$limits[$type]['sent'];
|
||||
}
|
||||
\Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT));
|
||||
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
|
||||
Log::debug('No limits reached, return FALSE.');
|
||||
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user