mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
remove is_migrating
This commit is contained in:
parent
74701e8b70
commit
dfb55dbd8b
@ -94,7 +94,9 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
if($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
MultiDB::setDB($this->company->db);
|
||||
|
||||
$this->setMailDriver();
|
||||
|
@ -57,7 +57,7 @@ class BaseMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that our token is refresh and valid we can boot the
|
||||
* Now that our token is refreshed and valid we can boot the
|
||||
* mail driver at runtime and also set the token which will persist
|
||||
* just for this request.
|
||||
*/
|
||||
|
@ -71,14 +71,13 @@ class EntityPaidMailer extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->company_users->first()->is_migrating) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//if we need to set an email driver do it now
|
||||
$this->setMailDriver();
|
||||
|
||||
|
@ -75,6 +75,10 @@ class EntitySentMailer extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
|
@ -75,7 +75,10 @@ class EntityViewedMailer extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
|
@ -67,6 +67,10 @@ class MailRouter extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
//if we need to set an email driver do it now
|
||||
|
@ -76,6 +76,10 @@ class PaymentFailureMailer extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/*If we are migrating data we don't want to fire these notification*/
|
||||
if ($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
|
@ -32,18 +32,21 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
private $contact;
|
||||
|
||||
private $company;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Payment $payment
|
||||
* @param $email_builder
|
||||
* @param $contact
|
||||
* @param $company
|
||||
*/
|
||||
public function __construct(Payment $payment, $email_builder, $contact)
|
||||
public function __construct(Payment $payment, $email_builder, $contact, company)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
$this->email_builder = $email_builder;
|
||||
$this->contact = $contact;
|
||||
$this->company = $company;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,6 +57,9 @@ class EmailPayment extends BaseMailerJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
if ($this->contact->email) {
|
||||
|
||||
MultiDB::setDb($this->payment->company->db); //this may fail if we don't pass the serialized object with the company record
|
||||
|
@ -54,6 +54,9 @@ class UserEmailChanged extends BaseMailerJob implements ShouldQueue
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if($this->company->is_disabled)
|
||||
return true;
|
||||
|
||||
//Set DB
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
|
@ -79,7 +79,8 @@ class StartMigration implements ShouldQueue
|
||||
|
||||
auth()->user()->setCompany($this->company);
|
||||
|
||||
$this->company->setMigration(true);
|
||||
$this->company->is_disabled = true;
|
||||
$this->company->save();
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$archive = $zip->open($this->filepath);
|
||||
|
@ -48,12 +48,13 @@ class PaymentNotification implements ShouldQueue
|
||||
MultiDB::setDb($event->company->db);
|
||||
|
||||
$payment = $event->payment;
|
||||
|
||||
if ($event->company->is_disabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*User notifications*/
|
||||
foreach ($payment->company->company_users as $company_user) {
|
||||
if ($company_user->is_migrating) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$user = $company_user->user;
|
||||
|
||||
|
@ -443,13 +443,5 @@ class Company extends BaseModel
|
||||
return $this->slack_webhook_url;
|
||||
}
|
||||
|
||||
public function setMigration($status)
|
||||
{
|
||||
$company_users = CompanyUser::where('company_id', $this->id)->get();
|
||||
|
||||
foreach ($company_users as $cu) {
|
||||
$cu->is_migrating = $status;
|
||||
$cu->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,11 +43,10 @@ class UserRepository extends BaseRepository
|
||||
* @param array $data The data
|
||||
* @param \App\Models\user $user The user
|
||||
*
|
||||
* @param bool $is_migrating
|
||||
* @param bool $unset_company_user
|
||||
* @return user|\App\Models\user|null user Object
|
||||
*/
|
||||
public function save(array $data, User $user, $is_migrating = false, $unset_company_user = false)
|
||||
public function save(array $data, User $user, $unset_company_user = false)
|
||||
{
|
||||
$details = $data;
|
||||
|
||||
@ -85,7 +84,6 @@ class UserRepository extends BaseRepository
|
||||
if (! $cu) {
|
||||
$data['company_user']['account_id'] = $account->id;
|
||||
$data['company_user']['notifications'] = CompanySettings::notificationDefaults();
|
||||
$data['company_user']['is_migrating'] = $is_migrating;
|
||||
$user->companies()->attach($company->id, $data['company_user']);
|
||||
} else {
|
||||
$cu->fill($data['company_user']);
|
||||
@ -108,8 +106,6 @@ class UserRepository extends BaseRepository
|
||||
public function destroy(array $data, User $user)
|
||||
{
|
||||
|
||||
info("destroy user");
|
||||
|
||||
if (array_key_exists('company_user', $data)) {
|
||||
$this->forced_includes = 'company_users';
|
||||
|
||||
@ -136,8 +132,6 @@ info("destroy user");
|
||||
public function delete($user)
|
||||
{
|
||||
|
||||
info("delete user");
|
||||
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$cu = CompanyUser::whereUserId($user->id)
|
||||
|
@ -37,7 +37,7 @@ class SendEmail
|
||||
|
||||
$this->payment->client->contacts->each(function ($contact) use ($email_builder) {
|
||||
if ($contact->send && $contact->email) {
|
||||
EmailPayment::dispatchNow($this->payment, $email_builder, $contact);
|
||||
EmailPayment::dispatchNow($this->payment, $email_builder, $contact, $this->payment->company);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ trait UserNotifies
|
||||
{
|
||||
public function findUserNotificationTypes($invitation, $company_user, $entity_name, $required_permissions) :array
|
||||
{
|
||||
if ($this->migrationRunning($company_user)) {
|
||||
if ($company_user->company->is_disabled) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -79,8 +79,4 @@ trait UserNotifies
|
||||
return $notifiable_methods;
|
||||
}
|
||||
|
||||
private function migrationRunning($company_user)
|
||||
{
|
||||
return $company_user->is_migrating;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class DropMigratingColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('company_user', function(Blueprint $table){
|
||||
$table->dropColumn('is_migrating');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user