email assignment notification force

This commit is contained in:
Yuri Kuznetsov
2024-10-09 16:07:47 +03:00
parent d2fc0c778b
commit 1aa004b0a6
4 changed files with 19 additions and 12 deletions
@@ -84,8 +84,10 @@ class Email implements AssignmentNotificator
return;
}
if ($entity->getStatus() !== EmailEntity::STATUS_BEING_IMPORTED) {
// @todo Find out whether it may happen
if (
$entity->getStatus() !== EmailEntity::STATUS_BEING_IMPORTED &&
!$this->streamService->checkIsEnabled(EmailEntity::ENTITY_TYPE)
) {
$this->defaultAssignmentNotificator->process(
$entity,
$params->withOption(DefaultAssignmentNotificator::OPTION_FORCE_ASSIGNED_USER, true)
@@ -1,3 +1,4 @@
{
"assignmentNotificatorClassName": "Espo\\Classes\\AssignmentNotificators\\Email"
"assignmentNotificatorClassName": "Espo\\Classes\\AssignmentNotificators\\Email",
"forceAssignmentNotificator": true
}
@@ -80,11 +80,7 @@ class HookProcessor
* No need to process assignment notifications for entity types that have Stream enabled.
* Users are notified via Stream notifications.
*/
if (
$hasStream &&
!$force &&
!$entity->hasLinkMultipleField('assignedUsers')
) {
if ($hasStream && !$force) {
return;
}
+12 -4
View File
@@ -185,7 +185,7 @@ class Service
*/
public function followEntityMass(Entity $entity, array $sourceUserIdList, bool $skipAclCheck = false): void
{
if (!$this->metadata->get(['scopes', $entity->getEntityType(), 'stream'])) {
if (!$this->checkIsEnabled($entity->getEntityType())) {
return;
}
@@ -275,7 +275,7 @@ class Service
return false;
}
if (!$this->metadata->get(['scopes', $entity->getEntityType(), 'stream'])) {
if (!$this->checkIsEnabled($entity->getEntityType())) {
return false;
}
@@ -318,7 +318,7 @@ class Service
public function unfollowEntity(Entity $entity, string $userId): bool
{
if (!$this->metadata->get(['scopes', $entity->getEntityType(), 'stream'])) {
if (!$this->checkIsEnabled($entity->getEntityType())) {
return false;
}
@@ -1117,7 +1117,7 @@ class Service
*/
public function getSubscriberList(string $parentType, string $parentId, bool $isInternal = false): Collection
{
if (!$this->metadata->get(['scopes', $parentType, 'stream'])) {
if (!$this->checkIsEnabled($parentType)) {
/** @var Collection<User> */
return $this->entityManager->getCollectionFactory()->create(User::ENTITY_TYPE);
}
@@ -1244,4 +1244,12 @@ class Service
$note->setData(['assignedUserId' => null]);
}
/**
* Whether the Stream is enabled for an entity type.
*/
public function checkIsEnabled(string $entityType): bool
{
return (bool) $this->metadata->get("scopes.$entityType.stream");
}
}