case link checker use originalEmailId

This commit is contained in:
Yuri Kuznetsov
2024-10-09 10:29:05 +03:00
parent db79d30efb
commit 64ff2df0c5
4 changed files with 35 additions and 18 deletions
@@ -59,15 +59,13 @@ class AccountLinkChecker implements LinkChecker
return false;
}
$emailIds = $entity->getLinkMultipleIdList('emails');
$emailId = $entity->get('originalEmailId');
if (count($emailIds) === 0 || count($emailIds) > 1) {
if (!$emailId) {
return false;
}
$email = $this->entityManager
->getRepositoryByClass(Email::class)
->getById($emailIds[0]);
$email = $this->entityManager->getRepositoryByClass(Email::class)->getById($emailId);
if (!$email) {
return false;
@@ -59,15 +59,13 @@ class ContactLinkChecker implements LinkChecker
return false;
}
$emailIds = $entity->getLinkMultipleIdList('emails');
$emailId = $entity->get('originalEmailId');
if (count($emailIds) === 0 || count($emailIds) > 1) {
if (!$emailId) {
return false;
}
$email = $this->entityManager
->getRepositoryByClass(Email::class)
->getById($emailIds[0]);
$email = $this->entityManager->getRepositoryByClass(Email::class)->getById($emailId);
if (!$email) {
return false;
@@ -59,15 +59,14 @@ class LeadLinkChecker implements LinkChecker
return false;
}
$emailIds = $entity->getLinkMultipleIdList('emails');
if (count($emailIds) === 0 || count($emailIds) > 1) {
$emailId = $entity->get('originalEmailId');
if (!$emailId) {
return false;
}
$email = $this->entityManager
->getRepositoryByClass(Email::class)
->getById($emailIds[0]);
$email = $this->entityManager->getRepositoryByClass(Email::class)->getById($emailId);
if (!$email) {
return false;
+25 -3
View File
@@ -320,7 +320,7 @@ class LinkTest extends BaseTestCase
'assignedUserId' => $user->getId(),
'leadId' => $lead->getId(),
'accountId' => $account->getId(),
'emailsIds' => [$email->getId()]
'originalEmailId' => $email->getId(),
], CreateParams::create());
//
@@ -357,7 +357,7 @@ class LinkTest extends BaseTestCase
'name' => '1',
'assignedUserId' => $user->getId(),
'accountId' => $account->getId(),
'emailsIds' => [$email->getId()]
'originalEmailId' => $email->getId(),
], CreateParams::create());
//
@@ -399,8 +399,30 @@ class LinkTest extends BaseTestCase
'accountId' => $account->getId(),
'contactId' => $contact->getId(),
'contactsIds' => [$contact->getId()],
'emailsIds' => [$email->getId()]
'originalEmailId' => $email->getId(),
], CreateParams::create());
// Should not allow more than 1 ID.
$contactAnother = $this->getEntityManager()->createEntity(Contact::ENTITY_TYPE);
$isThrown = false;
try {
/** @noinspection PhpUnhandledExceptionInspection */
$caseService->create((object) [
'name' => '1',
'assignedUserId' => $user->getId(),
'contactId' => $contact->getId(),
'contactsIds' => [$contact->getId(), $contactAnother->getId()],
'originalEmailId' => $email->getId(),
], CreateParams::create());
}
catch (Forbidden) {
$isThrown = true;
}
$this->assertTrue($isThrown);
}
public function testLoadNames(): void