Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsov8a8de3094932
diff --git a/application/Espo/Repositories/Email.php b/application/Espo/Repositories/Email.php
index 86d3378612..8299f2e626 100644
--- a/application/Espo/Repositories/Email.php
+++ b/application/Espo/Repositories/Email.php
@@ -75,31 +75,43 @@ class Email extends Database implements
self::ADDRESS_REPLY_TO,
];
- protected function prepareAddresses(EmailEntity $entity, string $type, bool $addAssignedUser = false): void
- {
+ private function prepareAddresses(
+ EmailEntity $entity,
+ string $type,
+ bool $addAssignedUser = false,
+ bool $skipUsers = false,
+ ): void {
+
if (!$entity->has($type)) {
return;
}
+ $link = $type . 'EmailAddresses';
+
$addressValue = $entity->get($type);
- $idList = [];
- if ($addressValue) {
- $addressList = $this->explodeAndPrepareAddressList($addressValue);
+ if (!$addressValue) {
+ $entity->setLinkMultipleIdList($link, []);
+
+ return;
+ }
+
+ $addressList = $this->explodeAndPrepareAddressList($addressValue);
- $idList = $this->getEmailAddressRepository()->getIdListFormAddressList($addressList);
+ $ids = $this->getEmailAddressRepository()->getIdListFormAddressList($addressList);
- if ($type !== self::ADDRESS_REPLY_TO) {
- foreach ($idList as $id) {
- $this->addUserByEmailAddressId($entity, $id, $addAssignedUser);
- }
- }
+ $entity->setLinkMultipleIdList($link, $ids);
+
+ if ($skipUsers) {
+ return;
}
- $entity->setLinkMultipleIdList($type . 'EmailAddresses', $idList);
+ foreach ($ids as $id) {
+ $this->addUserByEmailAddressId($entity, $id, $addAssignedUser);
+ }
}
- protected function addUserByEmailAddressId(
+ private function addUserByEmailAddressId(
EmailEntity $entity,
string $emailAddressId,
bool $addAssignedUser = false
@@ -491,7 +503,7 @@ class Email extends Database implements
}
if ($entity->has(self::ADDRESS_REPLY_TO)) {
- $this->prepareAddresses($entity, self::ADDRESS_REPLY_TO);
+ $this->prepareAddresses($entity, self::ADDRESS_REPLY_TO, false, true);
}
}