more import eml attachment check

This commit is contained in:
Yurii
2026-03-24 21:00:50 +02:00
parent d7a5205f0d
commit 0391b4b331
2 changed files with 20 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
namespace Espo\Entities;
use Espo\Core\Field\Link;
use Espo\Core\Name\Field;
use Espo\Core\ORM\Entity;
@@ -215,4 +216,13 @@ class Attachment extends Entity
return $this;
}
/**
* @since 9.3.5
*/
public function getCreatedBy(): ?Link
{
/** @var ?Link */
return $this->getValueObject(Field::CREATED_BY);
}
}

View File

@@ -48,6 +48,8 @@ use Espo\Tools\Email\ImportEmlService;
*/
class PostImportEml implements Action
{
private const string RELATED_TYPE = 'ImportEml';
public function __construct(
private Acl $acl,
private User $user,
@@ -88,6 +90,14 @@ class PostImportEml implements Action
throw new Forbidden("No access to attachment.");
}
if ($attachment->getCreatedBy()?->getId() !== $this->user->getId()) {
throw new Forbidden("Attachment is not owned.");
}
if ($attachment->getRelatedType() !== self::RELATED_TYPE) {
throw new Forbidden("Attachment is not for import EML.");
}
return $attachment;
}