|
@@ -2,14 +2,17 @@
|
|
|
|
|
|
namespace App\Services\Notification\ActionEmail;
|
|
namespace App\Services\Notification\ActionEmail;
|
|
|
|
|
|
|
|
+use App\Mail\ContainerAction;
|
|
use App\Mail\RequirementAction;
|
|
use App\Mail\RequirementAction;
|
|
use App\Mail\TaskAction;
|
|
use App\Mail\TaskAction;
|
|
use App\Models\Action;
|
|
use App\Models\Action;
|
|
|
|
+use App\Models\Container;
|
|
use App\Models\Enums\ActionObjectType;
|
|
use App\Models\Enums\ActionObjectType;
|
|
use App\Models\Enums\ObjectAction;
|
|
use App\Models\Enums\ObjectAction;
|
|
use App\Models\Requirement;
|
|
use App\Models\Requirement;
|
|
use App\Models\Task;
|
|
use App\Models\Task;
|
|
use App\Models\User;
|
|
use App\Models\User;
|
|
|
|
+use App\Repositories\ActionRepository;
|
|
use App\Repositories\ConfigRepository;
|
|
use App\Repositories\ConfigRepository;
|
|
use Illuminate\Contracts\Mail\Mailable;
|
|
use Illuminate\Contracts\Mail\Mailable;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Illuminate\Support\Facades\Mail;
|
|
@@ -18,6 +21,8 @@ class ActionEmailService
|
|
{
|
|
{
|
|
protected ObjectAction $objectAction;
|
|
protected ObjectAction $objectAction;
|
|
|
|
|
|
|
|
+ protected array $actions = [];
|
|
|
|
+
|
|
public function __construct(
|
|
public function __construct(
|
|
protected Action $action
|
|
protected Action $action
|
|
)
|
|
)
|
|
@@ -37,22 +42,30 @@ class ActionEmailService
|
|
|
|
|
|
$actionObjectModel = $actionObjectType->modelBuilder()->find($this->action->object_id);
|
|
$actionObjectModel = $actionObjectType->modelBuilder()->find($this->action->object_id);
|
|
|
|
|
|
|
|
+ $this->actions = ActionRepository::objectEmailActions($actionObjectType, $actionObjectModel->id, $this->action->id);
|
|
|
|
+
|
|
match ($actionObjectType) {
|
|
match ($actionObjectType) {
|
|
ActionObjectType::REQUIREMENT => $this->requirement($actionObjectModel),
|
|
ActionObjectType::REQUIREMENT => $this->requirement($actionObjectModel),
|
|
ActionObjectType::TASK => $this->task($actionObjectModel),
|
|
ActionObjectType::TASK => $this->task($actionObjectModel),
|
|
|
|
+ ActionObjectType::CONTAINER => $this->container($actionObjectModel),
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected function container(Container $container)
|
|
|
|
+ {
|
|
|
|
+ $this->dispatch($container->mailto, new ContainerAction($container, $this->objectAction, $this->actions));
|
|
|
|
+ }
|
|
|
|
+
|
|
protected function requirement(Requirement $requirement)
|
|
protected function requirement(Requirement $requirement)
|
|
{
|
|
{
|
|
- $this->dispatch($requirement->mailto, new RequirementAction($requirement, $this->objectAction));
|
|
|
|
|
|
+ $this->dispatch($requirement->mailto, new RequirementAction($requirement, $this->objectAction, $this->actions));
|
|
}
|
|
}
|
|
|
|
|
|
protected function task(Task $task)
|
|
protected function task(Task $task)
|
|
{
|
|
{
|
|
$userIds = array_filter([$task->assign, ...$task->mailto]);
|
|
$userIds = array_filter([$task->assign, ...$task->mailto]);
|
|
|
|
|
|
- $this->dispatch($userIds, new TaskAction($task, $this->objectAction));
|
|
|
|
|
|
+ $this->dispatch($userIds, new TaskAction($task, $this->objectAction, $this->actions));
|
|
}
|
|
}
|
|
|
|
|
|
protected function dispatch(array $userIds, Mailable $mailable)
|
|
protected function dispatch(array $userIds, Mailable $mailable)
|