Fix the ability to start new Conversations

This commit is contained in:
Antoine Le Gonidec 2024-07-22 18:14:42 +02:00
parent f861f240d1
commit 08bf27298c
Signed by: vv221
GPG key ID: 636B78F91CEB80D8
2 changed files with 8 additions and 0 deletions

View file

@ -59,6 +59,7 @@ class Customer extends BaseCustomer {
::where('id', '=', $id)
->whereIn('mailbox_id', $mailboxes)
->first($columns);
return $customer;
}
/**

View file

@ -15,6 +15,7 @@ use Illuminate\Support\ServiceProvider;
use App\User;
use Modules\MMFRestrictedCustomers\Console\Commands\FetchEmails;
use Modules\MMFRestrictedCustomers\Entities\Customer;
class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
/**
@ -69,6 +70,12 @@ class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
if ( array_key_exists('mailbox_id', $data) ) {
$customer->mailbox_id = $data['mailbox_id'];
} else {
$customer = Customer::find($customer->id);
if ( $customer == null ) {
Log::error('Trying to use a Customer in another Mailbox than the one it is linked to is not allowed, and has been aborted.');
// TODO: Error out more gracefully.
abort(500, 'Trying to use a Customer in another Mailbox than the one it is linked to is not allowed, and has been aborted.');
}
if ( $customer->mailbox_id == null ) {
Log::error('The creation of a Customer with no link to a Mailbox is not allowed, and has been aborted.');
// TODO: Error out more gracefully.