mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-22 08:56:39 -06:00
Final things.
This commit is contained in:
parent
206845575c
commit
97a687e40a
59
app/Api/V1/Controllers/System/CronController.php
Normal file
59
app/Api/V1/Controllers/System/CronController.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* CronController.php
|
||||||
|
* Copyright (c) 2021 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Controllers\System;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Api\V1\Controllers\Controller;
|
||||||
|
use FireflyIII\Api\V1\Requests\System\CronRequest;
|
||||||
|
use FireflyIII\Support\Http\Controllers\CronRunner;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CronController
|
||||||
|
*/
|
||||||
|
class CronController extends Controller
|
||||||
|
{
|
||||||
|
use CronRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CronRequest $request
|
||||||
|
* @param string $token
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function cron(CronRequest $request, string $token): JsonResponse
|
||||||
|
{
|
||||||
|
$config = $request->getAll();
|
||||||
|
|
||||||
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
|
|
||||||
|
$return = [];
|
||||||
|
$return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']);
|
||||||
|
$return['auto_budgets'] = $this->runAutoBudget($config['force'], $config['date']);
|
||||||
|
$return['telemetry'] = $this->runTelemetry($config['force'], $config['date']);
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json($return);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
83
app/Api/V1/Requests/System/CronRequest.php
Normal file
83
app/Api/V1/Requests/System/CronRequest.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ConfigurationRequest.php
|
||||||
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Api\V1\Requests\System;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CronRequest
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
class CronRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use ConvertsDataTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all data from the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAll(): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'force' => false,
|
||||||
|
'date' => Carbon::now(),
|
||||||
|
];
|
||||||
|
if ($this->has('force')) {
|
||||||
|
$data['force'] = $this->boolean('force');
|
||||||
|
}
|
||||||
|
if ($this->has('date')) {
|
||||||
|
$data['date'] = $this->date('date');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rules that the incoming request must be matched against.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'force' => 'in:true,false',
|
||||||
|
'date' => 'date',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Factory;
|
namespace FireflyIII\Factory;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Log;
|
use Log;
|
||||||
@ -74,6 +75,9 @@ class TransactionGroupFactory
|
|||||||
if (null !== $title) {
|
if (null !== $title) {
|
||||||
$title = substr($title, 0, 1000);
|
$title = substr($title, 0, 1000);
|
||||||
}
|
}
|
||||||
|
if(0 === $collection->count()) {
|
||||||
|
throw new FireflyException('Created zero transaction journals.');
|
||||||
|
}
|
||||||
|
|
||||||
$group = new TransactionGroup;
|
$group = new TransactionGroup;
|
||||||
$group->user()->associate($this->user);
|
$group->user()->associate($this->user);
|
||||||
|
@ -22,26 +22,19 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\System;
|
namespace FireflyIII\Http\Controllers\System;
|
||||||
|
use Log;
|
||||||
use FireflyIII\Support\Http\Controllers\CronRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CronController
|
* Class CronController
|
||||||
*/
|
*/
|
||||||
class CronController
|
class CronController
|
||||||
{
|
{
|
||||||
use CronRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function cron(): string
|
public function cron()
|
||||||
{
|
{
|
||||||
$results = [];
|
Log::error('The cron endpoint has moved to GET /api/v1/cron/[token]');
|
||||||
$results[] = $this->runRecurring();
|
return response('The cron endpoint has moved to GET /api/v1/cron/[token]', 500);
|
||||||
$results[] = $this->runAutoBudget();
|
|
||||||
$results[] = $this->runTelemetry();
|
|
||||||
|
|
||||||
return implode("<br>\n", $results);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,16 +133,16 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function keys(): void
|
public function keys(): void
|
||||||
{
|
{
|
||||||
|
// switch on PHP version.
|
||||||
// switch on PHP version.
|
// switch on PHP version.
|
||||||
if (7 === PHP_MAJOR_VERSION) {
|
if (7 === PHP_MAJOR_VERSION) {
|
||||||
$rsa = new \phpseclib\Crypt\RSA;
|
$rsa = new \phpseclib\Crypt\RSA;
|
||||||
$keys = $rsa->createKey(4096);
|
$keys = $rsa->createKey(4096);
|
||||||
}
|
}
|
||||||
if (8 === PHP_MAJOR_VERSION) {
|
if (8 === PHP_MAJOR_VERSION) {
|
||||||
$keys = \phpseclib3\Crypt\RSA::createKeys(4096);
|
$keys = \phpseclib3\Crypt\RSA::createKey(4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[$publicKey, $privateKey] = [
|
[$publicKey, $privateKey] = [
|
||||||
Passport::keyPath('oauth-public.key'),
|
Passport::keyPath('oauth-public.key'),
|
||||||
Passport::keyPath('oauth-private.key'),
|
Passport::keyPath('oauth-private.key'),
|
||||||
|
@ -182,6 +182,9 @@ class Kernel extends HttpKernel
|
|||||||
//'throttle:60,1',
|
//'throttle:60,1',
|
||||||
'bindings',
|
'bindings',
|
||||||
],
|
],
|
||||||
|
'apiY' => [
|
||||||
|
'bindings',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* The priority-sorted list of middleware.
|
* The priority-sorted list of middleware.
|
||||||
|
@ -110,7 +110,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
// clear cache for user
|
// clear cache for user
|
||||||
app('preferences')->setForUser($recurrence->user, 'lastActivity', microtime());
|
app('preferences')->setForUser($recurrence->user, 'lastActivity', microtime());
|
||||||
|
|
||||||
Log::debug(sprintf('Now at recurrence #%d', $recurrence->id));
|
Log::debug(sprintf('Now at recurrence #%d of user #%d', $recurrence->id, $recurrence->user_id));
|
||||||
$createdReps = $this->handleRepetitions($recurrence);
|
$createdReps = $this->handleRepetitions($recurrence);
|
||||||
Log::debug(sprintf('Done with recurrence #%d', $recurrence->id));
|
Log::debug(sprintf('Done with recurrence #%d', $recurrence->id));
|
||||||
$result[$recurrence->user_id] = $result[$recurrence->user_id]->merge($createdReps);
|
$result[$recurrence->user_id] = $result[$recurrence->user_id]->merge($createdReps);
|
||||||
@ -153,6 +153,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
private function validRecurrence(Recurrence $recurrence): bool
|
private function validRecurrence(Recurrence $recurrence): bool
|
||||||
{
|
{
|
||||||
|
Log::debug(sprintf('Now filtering recurrence #%d, owned by user #%d', $recurrence->id, $recurrence->user_id));
|
||||||
// is not active.
|
// is not active.
|
||||||
if (!$this->active($recurrence)) {
|
if (!$this->active($recurrence)) {
|
||||||
Log::info(sprintf('Recurrence #%d is not active. Skipped.', $recurrence->id));
|
Log::info(sprintf('Recurrence #%d is not active. Skipped.', $recurrence->id));
|
||||||
@ -203,6 +204,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Log::debug('Will be included.');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
public function map(): void
|
public function map(): void
|
||||||
{
|
{
|
||||||
$this->mapApiRoutes();
|
$this->mapApiRoutes();
|
||||||
|
$this->mapCronApiRoutes();
|
||||||
$this->mapWebRoutes();
|
$this->mapWebRoutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +71,19 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
->group(base_path('routes/api.php'));
|
->group(base_path('routes/api.php'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the "api" routes for the application.
|
||||||
|
*
|
||||||
|
* These routes are typically stateless.
|
||||||
|
*/
|
||||||
|
protected function mapCronApiRoutes(): void
|
||||||
|
{
|
||||||
|
Route::prefix('api/v1/cron')
|
||||||
|
->middleware('apiY')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api-noauth.php'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the "web" routes for the application.
|
* Define the "web" routes for the application.
|
||||||
*
|
*
|
||||||
|
@ -33,12 +33,15 @@ use Exception;
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractCronjob
|
abstract class AbstractCronjob
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $timeBetweenRuns = 43200;
|
||||||
public $timeBetweenRuns = 43200;
|
protected Carbon $date;
|
||||||
/** @var Carbon */
|
protected bool $force;
|
||||||
protected $date;
|
|
||||||
/** @var bool */
|
public bool $jobFired;
|
||||||
protected $force;
|
public bool $jobSucceeded;
|
||||||
|
public bool $jobErrored;
|
||||||
|
|
||||||
|
public ?string $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractCronjob constructor.
|
* AbstractCronjob constructor.
|
||||||
@ -49,12 +52,16 @@ abstract class AbstractCronjob
|
|||||||
{
|
{
|
||||||
$this->force = false;
|
$this->force = false;
|
||||||
$this->date = today(config('app.timezone'));
|
$this->date = today(config('app.timezone'));
|
||||||
|
$this->jobErrored = false;
|
||||||
|
$this->jobSucceeded = false;
|
||||||
|
$this->jobFired = false;
|
||||||
|
$this->message = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
*
|
||||||
*/
|
*/
|
||||||
abstract public function fire(): bool;
|
abstract public function fire(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
|
@ -39,7 +39,7 @@ class AutoBudgetCronjob extends AbstractCronjob
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function fire(): bool
|
public function fire(): void
|
||||||
{
|
{
|
||||||
/** @var Configuration $config */
|
/** @var Configuration $config */
|
||||||
$config = app('fireflyconfig')->get('last_ab_job', 0);
|
$config = app('fireflyconfig')->get('last_ab_job', 0);
|
||||||
@ -54,8 +54,8 @@ class AutoBudgetCronjob extends AbstractCronjob
|
|||||||
Log::info(sprintf('It has been %s since the auto budget cron-job has fired.', $diffForHumans));
|
Log::info(sprintf('It has been %s since the auto budget cron-job has fired.', $diffForHumans));
|
||||||
if (false === $this->force) {
|
if (false === $this->force) {
|
||||||
Log::info('The auto budget cron-job will not fire now.');
|
Log::info('The auto budget cron-job will not fire now.');
|
||||||
|
$this->message = sprintf('It has been %s since the auto budget cron-job has fired. It will not fire now.', $diffForHumans);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire job regardless.
|
// fire job regardless.
|
||||||
@ -69,10 +69,7 @@ class AutoBudgetCronjob extends AbstractCronjob
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->fireAutoBudget();
|
$this->fireAutoBudget();
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,6 +82,13 @@ class AutoBudgetCronjob extends AbstractCronjob
|
|||||||
$job = app(CreateAutoBudgetLimits::class);
|
$job = app(CreateAutoBudgetLimits::class);
|
||||||
$job->setDate($this->date);
|
$job->setDate($this->date);
|
||||||
$job->handle();
|
$job->handle();
|
||||||
|
|
||||||
|
// get stuff from job:
|
||||||
|
$this->jobFired = true;
|
||||||
|
$this->jobErrored = false;
|
||||||
|
$this->jobSucceeded = true;
|
||||||
|
$this->message = 'Auto-budget cron job fired successfully.';
|
||||||
|
|
||||||
app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));
|
app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));
|
||||||
Log::info('Done with auto budget cron job task.');
|
Log::info('Done with auto budget cron job task.');
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Support\Cronjobs;
|
namespace FireflyIII\Support\Cronjobs;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Jobs\CreateRecurringTransactions;
|
use FireflyIII\Jobs\CreateRecurringTransactions;
|
||||||
use FireflyIII\Models\Configuration;
|
use FireflyIII\Models\Configuration;
|
||||||
@ -35,16 +36,17 @@ use Log;
|
|||||||
class RecurringCronjob extends AbstractCronjob
|
class RecurringCronjob extends AbstractCronjob
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return bool
|
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function fire(): bool
|
public function fire(): void
|
||||||
{
|
{
|
||||||
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
/** @var Configuration $config */
|
/** @var Configuration $config */
|
||||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||||
$lastTime = (int)$config->data;
|
$lastTime = (int)$config->data;
|
||||||
$diff = time() - $lastTime;
|
$diff = time() - $lastTime;
|
||||||
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), true);
|
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), true);
|
||||||
|
|
||||||
if (0 === $lastTime) {
|
if (0 === $lastTime) {
|
||||||
Log::info('Recurring transactions cron-job has never fired before.');
|
Log::info('Recurring transactions cron-job has never fired before.');
|
||||||
}
|
}
|
||||||
@ -53,8 +55,9 @@ class RecurringCronjob extends AbstractCronjob
|
|||||||
Log::info(sprintf('It has been %s since the recurring transactions cron-job has fired.', $diffForHumans));
|
Log::info(sprintf('It has been %s since the recurring transactions cron-job has fired.', $diffForHumans));
|
||||||
if (false === $this->force) {
|
if (false === $this->force) {
|
||||||
Log::info('The cron-job will not fire now.');
|
Log::info('The cron-job will not fire now.');
|
||||||
|
$this->message = sprintf('It has been %s since the recurring transactions cron-job has fired. It will not fire now.', $diffForHumans);
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire job regardless.
|
// fire job regardless.
|
||||||
@ -70,8 +73,6 @@ class RecurringCronjob extends AbstractCronjob
|
|||||||
$this->fireRecurring();
|
$this->fireRecurring();
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,6 +86,13 @@ class RecurringCronjob extends AbstractCronjob
|
|||||||
$job->setDate($this->date);
|
$job->setDate($this->date);
|
||||||
$job->setForce($this->force);
|
$job->setForce($this->force);
|
||||||
$job->handle();
|
$job->handle();
|
||||||
|
|
||||||
|
// get stuff from job:
|
||||||
|
$this->jobFired = true;
|
||||||
|
$this->jobErrored = false;
|
||||||
|
$this->jobSucceeded = true;
|
||||||
|
$this->message = 'Recurring transactions cron job fired successfully.';
|
||||||
|
|
||||||
app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));
|
app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));
|
||||||
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
|
Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
|
||||||
Log::info('Done with recurring cron job task.');
|
Log::info('Done with recurring cron job task.');
|
||||||
|
@ -40,13 +40,15 @@ class TelemetryCronjob extends AbstractCronjob
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function fire(): bool
|
public function fire(): void
|
||||||
{
|
{
|
||||||
// do not fire if telemetry is disabled.
|
// do not fire if telemetry is disabled.
|
||||||
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
|
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
|
||||||
Log::warning('Telemetry is disabled. The cron job will do nothing.');
|
$msg = 'Telemetry is disabled. The cron job will do nothing.';
|
||||||
|
$this->message = $msg;
|
||||||
|
Log::warning($msg);
|
||||||
|
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,8 +65,8 @@ class TelemetryCronjob extends AbstractCronjob
|
|||||||
Log::info(sprintf('It has been %s since the telemetry cron-job has fired.', $diffForHumans));
|
Log::info(sprintf('It has been %s since the telemetry cron-job has fired.', $diffForHumans));
|
||||||
if (false === $this->force) {
|
if (false === $this->force) {
|
||||||
Log::info('The cron-job will not fire now.');
|
Log::info('The cron-job will not fire now.');
|
||||||
|
$this->message = sprintf('It has been %s since the telemetry cron-job has fired. It will not fire now.', $diffForHumans);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire job regardless.
|
// fire job regardless.
|
||||||
@ -80,8 +82,6 @@ class TelemetryCronjob extends AbstractCronjob
|
|||||||
$this->fireTelemetry();
|
$this->fireTelemetry();
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +97,11 @@ class TelemetryCronjob extends AbstractCronjob
|
|||||||
$job->setForce($this->force);
|
$job->setForce($this->force);
|
||||||
$job->handle();
|
$job->handle();
|
||||||
|
|
||||||
|
$this->jobFired = true;
|
||||||
|
$this->jobErrored = false;
|
||||||
|
$this->jobSucceeded = true;
|
||||||
|
$this->message = 'Telemetry cron job fired successfully.';
|
||||||
|
|
||||||
// TODO remove old, submitted telemetry data.
|
// TODO remove old, submitted telemetry data.
|
||||||
|
|
||||||
app('fireflyconfig')->set('last_tm_job', (int)$this->date->format('U'));
|
app('fireflyconfig')->set('last_tm_job', (int)$this->date->format('U'));
|
||||||
|
@ -30,7 +30,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
use phpseclib3\Crypt\RSA;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trait CreateStuff
|
* Trait CreateStuff
|
||||||
@ -110,7 +110,7 @@ trait CreateStuff
|
|||||||
$keys = $rsa->createKey(4096);
|
$keys = $rsa->createKey(4096);
|
||||||
}
|
}
|
||||||
if (8 === PHP_MAJOR_VERSION) {
|
if (8 === PHP_MAJOR_VERSION) {
|
||||||
$keys = RSA::createKeys(4096);
|
$keys = \phpseclib3\Crypt\RSA::createKey(4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
[$publicKey, $privateKey] = [
|
[$publicKey, $privateKey] = [
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Support\Http\Controllers;
|
namespace FireflyIII\Support\Http\Controllers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
|
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
|
||||||
use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||||
@ -34,60 +35,97 @@ use FireflyIII\Support\Cronjobs\TelemetryCronjob;
|
|||||||
trait CronRunner
|
trait CronRunner
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @param bool $force
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function runAutoBudget(): string
|
protected function runAutoBudget(bool $force, Carbon $date): array
|
||||||
{
|
{
|
||||||
/** @var AutoBudgetCronjob $autoBudget */
|
/** @var AutoBudgetCronjob $autoBudget */
|
||||||
$autoBudget = app(AutoBudgetCronjob::class);
|
$autoBudget = app(AutoBudgetCronjob::class);
|
||||||
|
$autoBudget->setForce($force);
|
||||||
|
$autoBudget->setDate($date);
|
||||||
try {
|
try {
|
||||||
$result = $autoBudget->fire();
|
$autoBudget->fire();
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
return $e->getMessage();
|
return [
|
||||||
}
|
'job_fired' => false,
|
||||||
if (false === $result) {
|
'job_succeeded' => false,
|
||||||
return 'The auto budget cron job did not fire.';
|
'job_errored' => true,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'The auto budget cron job fired successfully.';
|
return [
|
||||||
|
'job_fired' => $autoBudget->jobFired,
|
||||||
|
'job_succeeded' => $autoBudget->jobSucceeded,
|
||||||
|
'job_errored' => $autoBudget->jobErrored,
|
||||||
|
'message' => $autoBudget->message,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @param bool $force
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function runRecurring(): string
|
protected function runRecurring(bool $force, Carbon $date): array
|
||||||
{
|
{
|
||||||
/** @var RecurringCronjob $recurring */
|
/** @var RecurringCronjob $recurring */
|
||||||
$recurring = app(RecurringCronjob::class);
|
$recurring = app(RecurringCronjob::class);
|
||||||
|
$recurring->setForce($force);
|
||||||
|
$recurring->setDate($date);
|
||||||
try {
|
try {
|
||||||
$result = $recurring->fire();
|
$recurring->fire();
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
return $e->getMessage();
|
return [
|
||||||
}
|
'job_fired' => false,
|
||||||
if (false === $result) {
|
'job_succeeded' => false,
|
||||||
return 'The recurring transaction cron job did not fire. It was fired less than half a day ago.';
|
'job_errored' => true,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'The recurring transaction cron job fired successfully.';
|
return [
|
||||||
|
'job_fired' => $recurring->jobFired,
|
||||||
|
'job_succeeded' => $recurring->jobSucceeded,
|
||||||
|
'job_errored' => $recurring->jobErrored,
|
||||||
|
'message' => $recurring->message,
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @param bool $force
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function runTelemetry(): string
|
protected function runTelemetry(bool $force, Carbon $date): array
|
||||||
{
|
{
|
||||||
/** @var TelemetryCronjob $telemetry */
|
/** @var TelemetryCronjob $telemetry */
|
||||||
$telemetry = app(TelemetryCronjob::class);
|
$telemetry = app(TelemetryCronjob::class);
|
||||||
|
$telemetry->setForce($force);
|
||||||
|
$telemetry->setDate($date);
|
||||||
try {
|
try {
|
||||||
$result = $telemetry->fire();
|
$telemetry->fire();
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
return $e->getMessage();
|
return [
|
||||||
}
|
'job_fired' => false,
|
||||||
if (false === $result) {
|
'job_succeeded' => false,
|
||||||
return 'The telemetry cron job did not fire.';
|
'job_errored' => true,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'The telemetry cron job fired successfully.';
|
return [
|
||||||
|
'job_fired' => $telemetry->jobFired,
|
||||||
|
'job_succeeded' => $telemetry->jobSucceeded,
|
||||||
|
'job_errored' => $telemetry->jobErrored,
|
||||||
|
'message' => $telemetry->message,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
### Changed
|
### Changed
|
||||||
- OAuth settings are visible for LDAP users.
|
- OAuth settings are visible for LDAP users.
|
||||||
- If you set `FIREFLY_III_LAYOUT=v2`, Firefly III will show you the new layout on pages where it's available.
|
- If you set `FIREFLY_III_LAYOUT=v2`, Firefly III will show you the new layout on pages where it's available.
|
||||||
|
- New favicon.
|
||||||
|
- Cron job endpoint has changed.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
- The current layout will no longer receive fixes and changes.
|
- The current layout will no longer receive fixes and changes.
|
||||||
@ -48,6 +50,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- [Issue 4235](https://github.com/firefly-iii/firefly-iii/issues/4235) Info popup instandard financial report does not apply report's account filter
|
- [Issue 4235](https://github.com/firefly-iii/firefly-iii/issues/4235) Info popup instandard financial report does not apply report's account filter
|
||||||
- [Issue 4241](https://github.com/firefly-iii/firefly-iii/issues/4241) Broken chart
|
- [Issue 4241](https://github.com/firefly-iii/firefly-iii/issues/4241) Broken chart
|
||||||
- PHP configs that have "MB" as size indicator would be parsed badly.
|
- PHP configs that have "MB" as size indicator would be parsed badly.
|
||||||
|
- RSA token generation is now PHP7/8 compatible.
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- [Issue 4394](https://github.com/firefly-iii/firefly-iii/issues/4394) Storing budgets works again.
|
- [Issue 4394](https://github.com/firefly-iii/firefly-iii/issues/4394) Storing budgets works again.
|
||||||
- [Issue 4426](https://github.com/firefly-iii/firefly-iii/issues/4426) Storing accounts would lead to bad capitalization in liability type.
|
- [Issue 4426](https://github.com/firefly-iii/firefly-iii/issues/4426) Storing accounts would lead to bad capitalization in liability type.
|
||||||
- [Issue 4435](https://github.com/firefly-iii/firefly-iii/issues/4435) Storing piggy banks with object group information would fail.
|
- [Issue 4435](https://github.com/firefly-iii/firefly-iii/issues/4435) Storing piggy banks with object group information would fail.
|
||||||
|
- Users can submit almost any field without other fields changing as well.
|
||||||
|
|
||||||
## 5.4.6 (API 1.4.0) - 2020-10-07
|
## 5.4.6 (API 1.4.0) - 2020-10-07
|
||||||
|
|
||||||
|
13
routes/api-noauth.php
Normal file
13
routes/api-noauth.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
// Cron job API routes:
|
||||||
|
Route::group(
|
||||||
|
[
|
||||||
|
'namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => '',
|
||||||
|
'as' => 'api.v1.cron.'],
|
||||||
|
static function () {
|
||||||
|
Route::get('{cliToken}', ['uses' => 'CronController@cron', 'as' => 'index']);
|
||||||
|
}
|
||||||
|
);
|
@ -510,6 +510,8 @@ Route::group(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Configuration API routes
|
// Configuration API routes
|
||||||
Route::group(
|
Route::group(
|
||||||
['namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'configuration',
|
['namespace' => 'FireflyIII\Api\V1\Controllers\System', 'prefix' => 'configuration',
|
||||||
|
Loading…
Reference in New Issue
Block a user