From 7469ca30eb8b2cfeaa531cda0cc77ef0ddefb1f0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Jun 2021 18:06:34 +1000 Subject: [PATCH 1/2] HostedUsers console command --- app/Console/Commands/HostedUsers.php | 59 ++++++++++++++++++++++++++++ app/Jobs/Account/CreateAccount.php | 11 ++---- 2 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 app/Console/Commands/HostedUsers.php diff --git a/app/Console/Commands/HostedUsers.php b/app/Console/Commands/HostedUsers.php new file mode 100644 index 000000000000..793ff965a0fe --- /dev/null +++ b/app/Console/Commands/HostedUsers.php @@ -0,0 +1,59 @@ +all()->each(function ($company){ + + if(Ninja::isHosted()) + \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); + + }); + + Company::on('db-ninja-02')->all()->each(function ($company){ + + if(Ninja::isHosted()) + \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); + + }); + } + +} diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index 32490cf2e01c..6be9106205a4 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -104,7 +104,10 @@ class CreateAccount //todo implement SLACK notifications //$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()) ->increment() @@ -118,10 +121,6 @@ class CreateAccount 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) { return strtolower($item->code) == $currency_code; })->first(); @@ -146,8 +145,6 @@ class CreateAccount $settings->language_id = (string)$language->id; } - //$timezone = Timezone::where('name', $data['geoplugin_timezone'])->first(); - if($timezone) { $settings->timezone_id = (string)$timezone->id; } From 2e1a6ef6c42456e11d919ca6afb92fd1d86265c7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Jun 2021 18:10:46 +1000 Subject: [PATCH 2/2] HostedUsers console command --- app/Console/Commands/HostedUsers.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/HostedUsers.php b/app/Console/Commands/HostedUsers.php index 793ff965a0fe..621102382e2f 100644 --- a/app/Console/Commands/HostedUsers.php +++ b/app/Console/Commands/HostedUsers.php @@ -41,19 +41,21 @@ class HostedUsers extends Command */ public function handle() { - Company::on('db-ninja-01')->all()->each(function ($company){ + + Company::on('db-ninja-01')->each(function ($company){ if(Ninja::isHosted()) \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); }); - Company::on('db-ninja-02')->all()->each(function ($company){ + Company::on('db-ninja-02')->each(function ($company){ if(Ninja::isHosted()) \Modules\Admin\Jobs\Account\NinjaUser::dispatchNow([], $company); }); + } }