diff --git a/application/Espo/Classes/AssignmentNotificators/Email.php b/application/Espo/Classes/AssignmentNotificators/Email.php index f0c413bd79..df56fe0038 100644 --- a/application/Espo/Classes/AssignmentNotificators/Email.php +++ b/application/Espo/Classes/AssignmentNotificators/Email.php @@ -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) diff --git a/application/Espo/Resources/metadata/notificationDefs/Email.json b/application/Espo/Resources/metadata/notificationDefs/Email.json index 0ad2c496d2..a70b7b8492 100644 --- a/application/Espo/Resources/metadata/notificationDefs/Email.json +++ b/application/Espo/Resources/metadata/notificationDefs/Email.json @@ -1,3 +1,4 @@ { - "assignmentNotificatorClassName": "Espo\\Classes\\AssignmentNotificators\\Email" + "assignmentNotificatorClassName": "Espo\\Classes\\AssignmentNotificators\\Email", + "forceAssignmentNotificator": true } diff --git a/application/Espo/Tools/Notification/HookProcessor.php b/application/Espo/Tools/Notification/HookProcessor.php index c808409e19..e696f91448 100644 --- a/application/Espo/Tools/Notification/HookProcessor.php +++ b/application/Espo/Tools/Notification/HookProcessor.php @@ -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; } diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php index cd82f0b508..5dc58face6 100644 --- a/application/Espo/Tools/Stream/Service.php +++ b/application/Espo/Tools/Stream/Service.php @@ -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 */ 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"); + } }