Compare commits

..

3 commits

Author SHA1 Message Date
d61183c0a8
1.1.1 bugfix release
* Fix the ability to start new Conversations.
* Log an explicit error when creating a new Conversation is aborted.
2024-07-22 18:16:51 +02:00
08bf27298c
Fix the ability to start new Conversations 2024-07-22 18:14:42 +02:00
f861f240d1
Log an explicit error when trying to create a Customer without a Mailbox 2024-07-22 18:05:54 +02:00
6 changed files with 34 additions and 10 deletions

View file

@ -1,3 +1,8 @@
1.1.1
* Fix the ability to start new Conversations.
* Log an explicit error when creating a new Conversation is aborted.
1.1.0 1.1.0
* Add compatibility with MMFCustomersGroups. * Add compatibility with MMFCustomersGroups.

View file

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

View file

@ -6,11 +6,16 @@
namespace Modules\MMFRestrictedCustomers\Providers; namespace Modules\MMFRestrictedCustomers\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Eventy; use Eventy;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
use App\User; use App\User;
use Modules\MMFRestrictedCustomers\Console\Commands\FetchEmails; use Modules\MMFRestrictedCustomers\Console\Commands\FetchEmails;
use Modules\MMFRestrictedCustomers\Entities\Customer;
class MMFRestrictedCustomersServiceProvider extends ServiceProvider { class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
/** /**
@ -57,13 +62,26 @@ class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
Eventy::addAction( Eventy::addAction(
'customer.set_data', 'customer.set_data',
function($customer, $data, $replace_data) { function($customer, $data, $replace_data) {
if ( isset($data['mailbox']) ) { if ( array_key_exists('mailbox', $data) ) {
// TODO: Check that the current user is allowed to access this Mailbox. // TODO: Check that the current user is allowed to access this Mailbox.
$data['mailbox_id'] = $data['mailbox']; $data['mailbox_id'] = $data['mailbox'];
unset($data['mailbox']); unset($data['mailbox']);
} }
// TODO: Throw an error if the Mailbox is not set. if ( array_key_exists('mailbox_id', $data) ) {
$customer->mailbox_id = $data['mailbox_id']; $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.
abort(500, 'The creation of a Customer with no link to a Mailbox is not allowed, and has been aborted.');
}
}
}, },
$priority = 20, $priority = 20,
$arguments = 3 $arguments = 3

View file

@ -33,11 +33,11 @@ So it is highly recommended to backup your customers database:
Download the [release tarball] and extract its content into `Modules/MMFRestrictedCustomers`. Download the [release tarball] and extract its content into `Modules/MMFRestrictedCustomers`.
[release tarball]: https://port.numenaute.org/MMF/freescout-restricted-customers/archive/1.1.0.tar.gz [release tarball]: https://port.numenaute.org/MMF/freescout-restricted-customers/archive/1.1.1.tar.gz
``` ```
wget https://port.numenaute.org/MMF/freescout-restricted-customers/archive/1.1.0.tar.gz -O freescout-restricted-customers-1.1.0.tar.gz wget https://port.numenaute.org/MMF/freescout-restricted-customers/archive/1.1.1.tar.gz -O freescout-restricted-customers-1.1.1.tar.gz
tar xf freescout-restricted-customers-1.1.0.tar.gz -C Modules tar xf freescout-restricted-customers-1.1.1.tar.gz -C Modules
mv Modules/freescout-restricted-customers Modules/MMFRestrictedCustomers mv Modules/freescout-restricted-customers Modules/MMFRestrictedCustomers
``` ```

View file

@ -1,7 +1,7 @@
{ {
"name": "millions-missing-france/freescout-restricted-customers", "name": "millions-missing-france/freescout-restricted-customers",
"description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes", "description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes",
"version": "1.1.0", "version": "1.1.1",
"type": "library", "type": "library",
"license": ["AGPL-3.0-only"], "license": ["AGPL-3.0-only"],
"authors": [ "authors": [

View file

@ -2,7 +2,7 @@
"name": "MMFRestrictedCustomers", "name": "MMFRestrictedCustomers",
"alias": "mmfrestrictedcustomers", "alias": "mmfrestrictedcustomers",
"description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes", "description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes",
"version": "1.1.0", "version": "1.1.1",
"detailsUrl": "", "detailsUrl": "",
"author": "Millions Missing FRANCE", "author": "Millions Missing FRANCE",
"authorUrl": "info@millionsmissing.fr", "authorUrl": "info@millionsmissing.fr",