mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -43,7 +43,7 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
];
|
||||
|
||||
// try get array from update server:
|
||||
$updateInfo = $this->contactServer($channel);
|
||||
$updateInfo = $this->contactServer($channel);
|
||||
if ('error' === $updateInfo['level']) {
|
||||
app('log')->error('Update information contains an error.');
|
||||
app('log')->error($updateInfo['message']);
|
||||
@@ -60,14 +60,14 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
{
|
||||
app('log')->debug(sprintf('Now in contactServer(%s)', $channel));
|
||||
// always fall back to current version:
|
||||
$return = [
|
||||
$return = [
|
||||
'version' => config('firefly.version'),
|
||||
'date' => today(config('app.timezone'))->startOfDay(),
|
||||
'level' => 'error',
|
||||
'message' => (string)trans('firefly.unknown_error'),
|
||||
];
|
||||
|
||||
$url = config('firefly.update_endpoint');
|
||||
$url = config('firefly.update_endpoint');
|
||||
app('log')->debug(sprintf('Going to call %s', $url));
|
||||
|
||||
try {
|
||||
@@ -95,7 +95,7 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
|
||||
return $return;
|
||||
}
|
||||
$body = (string)$res->getBody();
|
||||
$body = (string)$res->getBody();
|
||||
|
||||
try {
|
||||
$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
|
||||
@@ -114,8 +114,8 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
}
|
||||
|
||||
// parse response a bit. No message yet.
|
||||
$response = $json['firefly_iii'][$channel];
|
||||
$date = Carbon::createFromFormat('Y-m-d', $response['date']);
|
||||
$response = $json['firefly_iii'][$channel];
|
||||
$date = Carbon::createFromFormat('Y-m-d', $response['date']);
|
||||
if (false === $date) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
@@ -131,19 +131,19 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
private function parseResult(array $information): array
|
||||
{
|
||||
app('log')->debug('Now in parseResult()', $information);
|
||||
$return = [
|
||||
$return = [
|
||||
'level' => 'error',
|
||||
'message' => (string)trans('firefly.unknown_error'),
|
||||
];
|
||||
$current = config('firefly.version');
|
||||
$latest = $information['version'];
|
||||
$current = config('firefly.version');
|
||||
$latest = $information['version'];
|
||||
|
||||
// strip the 'v' from the version if it's there.
|
||||
if (str_starts_with($latest, 'v')) {
|
||||
$latest = substr($latest, 1);
|
||||
}
|
||||
|
||||
$compare = version_compare($latest, $current);
|
||||
$compare = version_compare($latest, $current);
|
||||
|
||||
app('log')->debug(sprintf('Current version is "%s", latest is "%s", result is: %d', $current, $latest, $compare));
|
||||
|
||||
@@ -166,10 +166,10 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
|
||||
// a newer version is available!
|
||||
/** @var Carbon $released */
|
||||
$released = $information['date'];
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
$diff = $today->diffInDays($released);
|
||||
$expectedDiff = config('firefly.update_minimum_age') ?? 6;
|
||||
$released = $information['date'];
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
$diff = $today->diffInDays($released);
|
||||
$expectedDiff = config('firefly.update_minimum_age') ?? 6;
|
||||
// it's still very fresh, and user wants a stable release:
|
||||
if ($diff <= $expectedDiff) {
|
||||
$return['level'] = 'info';
|
||||
@@ -200,13 +200,13 @@ class UpdateRequest implements UpdateRequestInterface
|
||||
|
||||
// add warning in case of alpha or beta:
|
||||
// append warning if beta or alpha.
|
||||
$isBeta = $information['is_beta'] ?? false;
|
||||
$isBeta = $information['is_beta'] ?? false;
|
||||
if (true === $isBeta) {
|
||||
$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_beta'));
|
||||
app('log')->debug('New release is also a beta!');
|
||||
}
|
||||
|
||||
$isAlpha = $information['is_alpha'] ?? false;
|
||||
$isAlpha = $information['is_alpha'] ?? false;
|
||||
if (true === $isAlpha) {
|
||||
$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_alpha'));
|
||||
app('log')->debug('New release is also a alpha!');
|
||||
|
Reference in New Issue
Block a user