action ID

This commit is contained in:
Yuri Kuznetsov
2025-06-30 19:03:55 +03:00
parent 0a7fe37014
commit 15de70c8f7
15 changed files with 216 additions and 96 deletions
@@ -29,6 +29,7 @@
namespace Espo\Core\Notification;
use Espo\Core\Field\LinkParent;
use Espo\Core\Name\Field;
use Espo\Core\ORM\Entity as CoreEntity;
use Espo\ORM\Entity;
@@ -72,7 +73,7 @@ class DefaultAssignmentNotificator implements AssignmentNotificator
continue;
}
$this->processForUser($entity, $userId);
$this->processForUser($entity, $userId, $params);
}
return;
@@ -88,10 +89,10 @@ class DefaultAssignmentNotificator implements AssignmentNotificator
$assignedUserId = $entity->get(self::ATTR_ASSIGNED_USER_ID);
$this->processForUser($entity, $assignedUserId);
$this->processForUser($entity, $assignedUserId, $params);
}
protected function processForUser(Entity $entity, string $assignedUserId): void
protected function processForUser(Entity $entity, string $assignedUserId, Params $params): void
{
if (!$this->userChecker->checkAssignment($entity->getEntityType(), $assignedUserId)) {
return;
@@ -113,19 +114,22 @@ class DefaultAssignmentNotificator implements AssignmentNotificator
return;
}
$this->entityManager->createEntity(Notification::ENTITY_TYPE, [
'type' => Notification::TYPE_ASSIGN,
'userId' => $assignedUserId,
'data' => [
$notification = $this->entityManager->getRDBRepositoryByClass(Notification::class)->getNew();
$notification
->setType(Notification::TYPE_ASSIGN)
->setUserId($assignedUserId)
->setData([
'entityType' => $entity->getEntityType(),
'entityId' => $entity->getId(),
'entityName' => $entity->get(Field::NAME),
'isNew' => $entity->isNew(),
'userId' => $this->user->getId(),
'userName' => $this->user->getName(),
],
'relatedType' => $entity->getEntityType(),
'relatedId' => $entity->getId(),
]);
])
->setRelated(LinkParent::createFromEntity($entity))
->setActionId($params->getActionId());
$this->entityManager->saveEntity($notification);
}
}