email do not set sent by if draft

This commit is contained in:
Yuri Kuznetsov
2024-11-09 10:54:26 +02:00
parent d7174c916e
commit 3443db832c
2 changed files with 8 additions and 1 deletions

View File

@@ -717,6 +717,11 @@ class Email extends Entity
return $this->getValueObject('sentBy');
}
public function setSentBy(Link|User|null $sentBy): self
{
return $this->setRelatedLinkOrEntity('sentBy', $sentBy);
}
public function getGroupFolder(): ?Link
{
/** @var ?Link */

View File

@@ -333,6 +333,7 @@ class Email extends Database implements
$this->addUserByEmailAddressId($entity, $ids[0], true);
if (!$entity->getSentBy()) {
/** @var UserEntity $user */
$user = $this->getEmailAddressRepository()
->getEntityByAddressId(
$entity->get('fromEmailAddressId'),
@@ -340,7 +341,8 @@ class Email extends Database implements
true
);
if ($user) {
if ($user && $entity->getStatus() !== EmailEntity::STATUS_DRAFT) {
$entity->setSentBy($user);
$entity->set('sentById', $user->getId());
}
}