mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Ensure companies have the correct size when there are heterogeneous user permissions
This commit is contained in:
parent
a8982cde44
commit
ea1f2945b2
@ -12,6 +12,7 @@
|
||||
namespace App\Jobs\Ninja;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@ -62,6 +63,22 @@ class CompanySizeCheck implements ShouldQueue
|
||||
|
||||
});
|
||||
|
||||
/* Ensures lower permissioned users return the correct dataset and refresh responses */
|
||||
Account::whereHas('companies', function ($query){
|
||||
$query->where('is_large',0);
|
||||
})
|
||||
->whereHas('company_users', function ($query){
|
||||
|
||||
$query->where('is_admin', 0);
|
||||
|
||||
})
|
||||
->cursor()->each(function ($account){
|
||||
|
||||
$account->companies()->update(['is_large' => true]);
|
||||
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
//multiDB environment, need to
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
@ -88,6 +105,22 @@ class CompanySizeCheck implements ShouldQueue
|
||||
|
||||
});
|
||||
|
||||
Account::where('plan', 'enterprise')
|
||||
->whereDate('plan_expires', '>', now())
|
||||
->whereHas('companies', function ($query){
|
||||
$query->where('is_large',0);
|
||||
})
|
||||
->whereHas('company_users', function ($query){
|
||||
|
||||
$query->where('is_admin', 0);
|
||||
|
||||
})
|
||||
->cursor()->each(function ($account){
|
||||
|
||||
$account->companies()->update(['is_large' => true]);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,17 +79,15 @@ class WebhookHandler implements ShouldQueue
|
||||
->cursor()
|
||||
->each(function ($subscription) {
|
||||
|
||||
// $this->process($subscription);
|
||||
|
||||
WebhookSingle::dispatch($subscription->id, $this->entity, $this->company->db, $this->includes);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function failed($exception)
|
||||
public function failed($exception = null)
|
||||
{
|
||||
|
||||
if($exception)
|
||||
nlog(print_r($exception->getMessage(), 1));
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user