Add a hook when sending a new conversation
This is still a work in progress, this hook has no actual effect on the recipients list yet.
This commit is contained in:
parent
48c129c812
commit
4a3410de81
1 changed files with 17 additions and 0 deletions
|
@ -9,8 +9,10 @@ namespace Modules\MMFCustomersGroups\Providers;
|
||||||
use Eventy;
|
use Eventy;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
use Modules\MMFCustomersGroups\Entities\CustomersGroup;
|
||||||
use Modules\MMFCustomersGroups\Entities\Mailbox;
|
use Modules\MMFCustomersGroups\Entities\Mailbox;
|
||||||
|
|
||||||
class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
||||||
|
@ -97,5 +99,20 @@ class MMFCustomersGroupsServiceProvider extends ServiceProvider {
|
||||||
],
|
],
|
||||||
)->render();
|
)->render();
|
||||||
}, 20, 3);
|
}, 20, 3);
|
||||||
|
|
||||||
|
// Update the list of recipients if some groups have been selected.
|
||||||
|
Eventy::addAction('conversation.send_reply_save', function($conversation, $request) {
|
||||||
|
$groups = $request->groups;
|
||||||
|
// Return early if no group has been selected.
|
||||||
|
if ( empty($groups) ) return;
|
||||||
|
// Get the list of e-mails included in the selected groups.
|
||||||
|
$emails = new Collection;
|
||||||
|
foreach ( $groups as $group_id ) {
|
||||||
|
$group = CustomersGroup::find($group_id);
|
||||||
|
$emails->concat($group->emails());
|
||||||
|
}
|
||||||
|
$emails = $emails->unique();
|
||||||
|
// TODO: Update $conversation to include this list of e-mails.
|
||||||
|
}, 20, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue