EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
more import eml attachment check
Yurii0391b4b33142
diff --git a/application/Espo/Entities/Attachment.php b/application/Espo/Entities/Attachment.phpindex 8c213d4d97..b0971e4e57 100644--- a/application/Espo/Entities/Attachment.php+++ b/application/Espo/Entities/Attachment.php@@ -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 Entityreturn $this;}++ /**+ * @since 9.3.5+ */+ public function getCreatedBy(): ?Link+ {+ /** @var ?Link */+ return $this->getValueObject(Field::CREATED_BY);+ }}diff --git a/application/Espo/Tools/Email/Api/PostImportEml.php b/application/Espo/Tools/Email/Api/PostImportEml.phpindex 2e11ac09e1..4ae5e2cd3d 100644--- a/application/Espo/Tools/Email/Api/PostImportEml.php+++ b/application/Espo/Tools/Email/Api/PostImportEml.php@@ -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 Actionthrow 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;}