2020-03-08 09:15:11 +11:00
|
|
|
<?php
|
2020-04-30 21:45:47 +10:00
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-04-30 21:45:47 +10:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2023-01-29 09:21:40 +11:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-04-30 21:45:47 +10:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-04-30 21:45:47 +10:00
|
|
|
*/
|
2020-03-08 09:15:11 +11:00
|
|
|
|
|
|
|
|
namespace App\Jobs\Util;
|
|
|
|
|
|
2020-03-08 16:59:06 +11:00
|
|
|
use App\Models\Account;
|
2021-04-20 22:45:35 +10:00
|
|
|
use App\Utils\Ninja;
|
2022-06-21 09:57:17 +00:00
|
|
|
use Carbon\Carbon;
|
2020-03-08 09:15:11 +11:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
|
|
class VersionCheck implements ShouldQueue
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the job.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function handle()
|
|
|
|
|
{
|
2022-07-25 08:00:52 +10:00
|
|
|
$version_file = trim(@file_get_contents(config('ninja.version_url')));
|
2020-03-08 09:15:11 +11:00
|
|
|
|
2022-07-10 10:56:37 +10:00
|
|
|
if (Ninja::isSelfHost() && $version_file) {
|
2020-03-08 16:59:06 +11:00
|
|
|
Account::whereNotNull('id')->update(['latest_version' => $version_file]);
|
2020-03-21 16:37:30 +11:00
|
|
|
}
|
2021-04-20 22:45:35 +10:00
|
|
|
|
2022-06-21 09:57:17 +00:00
|
|
|
if (Ninja::isSelfHost()) {
|
2022-11-26 11:09:48 +11:00
|
|
|
nlog("latest version = {$version_file}");
|
|
|
|
|
|
2021-04-20 22:45:35 +10:00
|
|
|
$account = Account::first();
|
|
|
|
|
|
2022-06-21 09:57:17 +00:00
|
|
|
if (! $account) {
|
2021-05-01 10:48:36 +10:00
|
|
|
return;
|
2022-06-21 09:57:17 +00:00
|
|
|
}
|
2021-05-01 10:48:36 +10:00
|
|
|
|
2022-06-21 09:57:17 +00:00
|
|
|
if ($account->plan == 'white_label' && $account->plan_expires && Carbon::parse($account->plan_expires)->lt(now())) {
|
2021-04-20 22:45:35 +10:00
|
|
|
$account->plan = null;
|
|
|
|
|
$account->plan_expires = null;
|
|
|
|
|
$account->save();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-08 09:15:11 +11:00
|
|
|
}
|
|
|
|
|
}
|