1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #6014 from turbo124/v5-develop

Hosted Users console command
This commit is contained in:
David Bomba 2021-06-14 18:11:07 +10:00 committed by GitHub
commit 7de18a5f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 7 deletions

View File

@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\User;
use App\Utils\Ninja;
use Illuminate\Console\Command;
class HostedUsers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:sync-users';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Syncs Invoice Ninja Users';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
Company::on('db-ninja-01')->each(function ($company){
if(Ninja::isHosted())
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
});
Company::on('db-ninja-02')->each(function ($company){
if(Ninja::isHosted())
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company);
});
}
}

View File

@ -104,7 +104,10 @@ class CreateAccount
//todo implement SLACK notifications //todo implement SLACK notifications
//$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja(); //$sp035a66->notification(new NewAccountCreated($spaa9f78, $sp035a66))->ninja();
VersionCheck::dispatchNow(); if(Ninja::isHosted())
\Modules\Admin\Jobs\Account\NinjaUser::dispatch([], $sp035a66);
VersionCheck::dispatch();
LightLogs::create(new AnalyticsAccountCreated()) LightLogs::create(new AnalyticsAccountCreated())
->increment() ->increment()
@ -118,10 +121,6 @@ class CreateAccount
if(Ninja::isHosted() && Cache::get('currencies')) if(Ninja::isHosted() && Cache::get('currencies'))
{ {
//&& $data = unserialize(@file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $this->client_ip))
// $currency_code = strtolower($data['geoplugin_currencyCode']);
// $country_code = strtolower($data['geoplugin_countryCode']);
$currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) { $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) {
return strtolower($item->code) == $currency_code; return strtolower($item->code) == $currency_code;
})->first(); })->first();
@ -146,8 +145,6 @@ class CreateAccount
$settings->language_id = (string)$language->id; $settings->language_id = (string)$language->id;
} }
//$timezone = Timezone::where('name', $data['geoplugin_timezone'])->first();
if($timezone) { if($timezone) {
$settings->timezone_id = (string)$timezone->id; $settings->timezone_id = (string)$timezone->id;
} }