fix email notifications

This commit is contained in:
yuri
2015-08-17 10:54:03 +03:00
parent 778e7b335e
commit d1dea478f7
2 changed files with 12 additions and 3 deletions

View File

@@ -99,6 +99,7 @@ class Importer
$usersIds = $duplicate->get('usersIds');
$usersIds[] = $userId;
$duplicate->set('usersIds', $usersIds);
$this->getEntityManager()->saveEntity($duplicate);
if (!empty($teamsIds)) {

View File

@@ -43,13 +43,17 @@ class Email extends \Espo\Core\Notificators\Base
public function process(Entity $entity)
{
if ($entity->get('status') != 'Archived' && $entity->get('status') != 'Sent') {
if ($entity->get('status') !== 'Archived' && $entity->get('status') !== 'Sent') {
return;
}
$previousUserIdList = $entity->getFetched('usersIds');
if (!is_array($previousUserIdList)) {
if ($entity->get('status') === 'Sent') {
$previousUserIdList = [];
} else {
$previousUserIdList = $entity->getFetched('usersIds');
if (!is_array($previousUserIdList)) {
$previousUserIdList = [];
}
}
$emailUserIdList = $entity->get('usersIds');
@@ -70,6 +74,10 @@ class Email extends \Espo\Core\Notificators\Base
'emailName' => $entity->get('name'),
);
if (!$entity->has('from')) {
$this->getEntityManager()->getRepository('Email')->loadFromField($entity);
}
$from = $entity->get('from');
if ($from) {
$person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddress($from, null, ['User', 'Contact', 'Lead']);