From 1edc3ead8d8336dfadbd10fce45b1dbdd7a676d7 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 22 Feb 2024 10:50:11 +0200 Subject: [PATCH] ref --- .../RecordHooks/Webhook/AfterDelete.php | 62 ++++++ .../Classes/RecordHooks/Webhook/AfterSave.php | 75 +++++++ .../RecordHooks/Webhook/BeforeSave.php | 186 +++++++++++++++++ application/Espo/Core/Record/Service.php | 12 +- .../Classes/RecordHooks/Case/AfterCreate.php | 70 +++++++ .../Classes/RecordHooks/Case/BeforeCreate.php | 69 +++++++ .../Crm/Resources/i18n/en_US/Case.json | 3 +- .../Resources/metadata/entityDefs/Case.json | 8 + .../Resources/metadata/recordDefs/Case.json | 8 +- .../metadata/recordDefs/Webhook.json | 17 ++ .../Espo/Modules/Crm/Services/CaseObj.php | 89 -------- application/Espo/Services/Webhook.php | 191 +----------------- client/src/views/email/detail.js | 2 +- 13 files changed, 506 insertions(+), 286 deletions(-) create mode 100644 application/Espo/Classes/RecordHooks/Webhook/AfterDelete.php create mode 100644 application/Espo/Classes/RecordHooks/Webhook/AfterSave.php create mode 100644 application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php create mode 100644 application/Espo/Modules/Crm/Classes/RecordHooks/Case/AfterCreate.php create mode 100644 application/Espo/Modules/Crm/Classes/RecordHooks/Case/BeforeCreate.php create mode 100644 application/Espo/Modules/Crm/Resources/metadata/recordDefs/Webhook.json delete mode 100644 application/Espo/Modules/Crm/Services/CaseObj.php diff --git a/application/Espo/Classes/RecordHooks/Webhook/AfterDelete.php b/application/Espo/Classes/RecordHooks/Webhook/AfterDelete.php new file mode 100644 index 0000000000..2b2109e94c --- /dev/null +++ b/application/Espo/Classes/RecordHooks/Webhook/AfterDelete.php @@ -0,0 +1,62 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Classes\RecordHooks\Webhook; + +use Espo\Core\Record\DeleteParams; +use Espo\Core\Record\Hook\DeleteHook; +use Espo\Core\Webhook\Manager; +use Espo\Entities\Webhook; +use Espo\ORM\Entity; + +/** + * @implements DeleteHook + * @noinspection PhpUnused + */ +class AfterDelete implements DeleteHook +{ + public function __construct( + private Manager $webhookManager + ) {} + + public function process(Entity $entity, DeleteParams $params): void + { + $event = $entity->getEvent(); + + if (!$event) { + return; + } + + if (!$entity->isActive()) { + return; + } + + $this->webhookManager->removeEvent($event); + } +} diff --git a/application/Espo/Classes/RecordHooks/Webhook/AfterSave.php b/application/Espo/Classes/RecordHooks/Webhook/AfterSave.php new file mode 100644 index 0000000000..c1b7023ff9 --- /dev/null +++ b/application/Espo/Classes/RecordHooks/Webhook/AfterSave.php @@ -0,0 +1,75 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Classes\RecordHooks\Webhook; + +use Espo\Core\Record\Hook\SaveHook; +use Espo\Core\Webhook\Manager; +use Espo\Entities\Webhook; +use Espo\ORM\Entity; +use RuntimeException; + +/** + * @implements SaveHook + */ +class AfterSave implements SaveHook +{ + public function __construct( + private Manager $webhookManager + ) {} + + public function process(Entity $entity): void + { + $event = $entity->getEvent(); + + if (!$event) { + throw new RuntimeException("No 'event'."); + } + + if ($entity->isNew()) { + if ($entity->isActive()) { + $this->webhookManager->addEvent($event); + } + + return; + } + + if (!$entity->isAttributeChanged('isActive')) { + return; + } + + if ($entity->isActive()) { + $this->webhookManager->addEvent($event); + + return; + } + + $this->webhookManager->removeEvent($event); + } +} diff --git a/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php b/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php new file mode 100644 index 0000000000..a463023be4 --- /dev/null +++ b/application/Espo/Classes/RecordHooks/Webhook/BeforeSave.php @@ -0,0 +1,186 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Classes\RecordHooks\Webhook; + +use Espo\Core\Acl; +use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Record\Hook\SaveHook; +use Espo\Core\Utils\Config; +use Espo\Core\Utils\Metadata; +use Espo\Entities\User; +use Espo\Entities\Webhook; +use Espo\ORM\Entity; +use Espo\ORM\EntityManager; + +/** + * @implements SaveHook + */ +class BeforeSave implements SaveHook +{ + private const WEBHOOK_MAX_COUNT_PER_USER = 50; + + /** @var string[] */ + private $eventTypeList = [ + 'create', + 'update', + 'delete', + 'fieldUpdate', + ]; + + public function __construct( + private User $user, + private EntityManager $entityManager, + private Acl $acl, + private Metadata $metadata, + private Config $config + ) {} + + public function process(Entity $entity): void + { + $this->checkEntityUserIsApi($entity); + $this->processEntityEventData($entity); + + if ($entity->isNew() && !$this->user->isAdmin()) { + $this->checkMaxCount(); + } + } + + /** + * @throws Forbidden + */ + private function checkEntityUserIsApi(Webhook $entity): void + { + $userId = $entity->getUserId(); + + if (!$userId) { + return; + } + + $user = $this->entityManager->getRDBRepositoryByClass(User::class)->getById($userId); + + if ($user && $user->isApi()) { + return; + } + + throw new Forbidden("User must be an API User."); + } + + /** + * @throws Forbidden + */ + private function processEntityEventData(Webhook $entity): void + { + $event = $entity->get('event'); + + if (!$event) { + throw new Forbidden("Event is empty."); + } + + if (!$entity->isNew() && $entity->isAttributeChanged('event')) { + throw new Forbidden("Event can't be changed."); + } + + $arr = explode('.', $event); + + if (count($arr) !== 2 && count($arr) !== 3) { + throw new Forbidden("Not supported event."); + } + + $entityType = $arr[0]; + $type = $arr[1]; + + $entity->set('entityType', $entityType); + $entity->set('type', $type); + + $field = null; + + if (!$entityType) { + throw new Forbidden("Entity Type is empty."); + } + + if (!$this->metadata->get(['scopes', $entityType, 'object'])) { + throw new Forbidden("Entity type is not available for Webhooks."); + } + + if (!$this->entityManager->hasRepository($entityType)) { + throw new Forbidden("Not existing Entity Type."); + } + + if (!$this->acl->checkScope($entityType, Acl\Table::ACTION_READ)) { + throw new Forbidden("Entity type is forbidden."); + } + + if (!in_array($type, $this->eventTypeList)) { + throw new Forbidden("Not supported event."); + } + + if ($type === 'fieldUpdate') { + if (count($arr) == 3) { + $field = $arr[2]; + } + + $entity->set('field', $field); + + if (!$field) { + throw new Forbidden("Field is empty."); + } + + if (!$this->acl->checkField($entityType, $field)) { + throw new Forbidden("Field is forbidden."); + } + + if (!$this->metadata->get(['entityDefs', $entityType, 'fields', $field])) { + throw new Forbidden("Field does not exist."); + } + + return; + } + + /** @noinspection PhpRedundantOptionalArgumentInspection */ + $entity->set('field', null); + } + + /** + * @throws Forbidden + */ + private function checkMaxCount(): void + { + $maxCount = $this->config->get('webhookMaxCountPerUser', self::WEBHOOK_MAX_COUNT_PER_USER); + + $count = $this->entityManager + ->getRDBRepositoryByClass(Webhook::class) + ->where(['userId' => $this->user->getId()]) + ->count(); + + if ($maxCount && $count >= $maxCount) { + throw new Forbidden("Webhook number per user exceeded the limit."); + } + } +} diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.php index 587a3acc31..13a6564a65 100644 --- a/application/Espo/Core/Record/Service.php +++ b/application/Espo/Core/Record/Service.php @@ -1960,7 +1960,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function beforeCreateEntity(Entity $entity, $data) {} @@ -1971,7 +1971,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function afterCreateEntity(Entity $entity, $data) {} @@ -1982,7 +1982,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function beforeUpdateEntity(Entity $entity, $data) {} @@ -1993,7 +1993,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function afterUpdateEntity(Entity $entity, $data) {} @@ -2003,7 +2003,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function beforeDeleteEntity(Entity $entity) {} @@ -2013,7 +2013,7 @@ class Service implements Crud, * @return void * @noinspection PhpDocSignatureInspection * @deprecated As of v8.2. - * @todo Remove in v10.0. + * @todo Remove (or add types) in v10.0. */ protected function afterDeleteEntity(Entity $entity) {} diff --git a/application/Espo/Modules/Crm/Classes/RecordHooks/Case/AfterCreate.php b/application/Espo/Modules/Crm/Classes/RecordHooks/Case/AfterCreate.php new file mode 100644 index 0000000000..d9621d9c3d --- /dev/null +++ b/application/Espo/Modules/Crm/Classes/RecordHooks/Case/AfterCreate.php @@ -0,0 +1,70 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Modules\Crm\Classes\RecordHooks\Case; + +use Espo\Core\Acl; +use Espo\Core\Field\LinkParent; +use Espo\Core\Record\Hook\SaveHook; +use Espo\Entities\Email; +use Espo\Modules\Crm\Entities\CaseObj; +use Espo\ORM\Entity; +use Espo\ORM\EntityManager; + +/** + * @implements SaveHook + * @noinspection PhpUnused + */ +class AfterCreate implements SaveHook +{ + public function __construct( + private EntityManager $entityManager, + private Acl $acl + ) {} + + public function process(Entity $entity): void + { + /** @var ?string $emailId */ + $emailId = $entity->get('originalEmailId'); + + if (!$emailId) { + return; + } + + $email = $this->entityManager->getRDBRepositoryByClass(Email::class)->getById($emailId); + + if (!$email || $email->getParentId() || !$this->acl->check($email)) { + return; + } + + $email->setParent(LinkParent::createFromEntity($entity)); + + $this->entityManager->saveEntity($email); + } +} diff --git a/application/Espo/Modules/Crm/Classes/RecordHooks/Case/BeforeCreate.php b/application/Espo/Modules/Crm/Classes/RecordHooks/Case/BeforeCreate.php new file mode 100644 index 0000000000..141be29f5f --- /dev/null +++ b/application/Espo/Modules/Crm/Classes/RecordHooks/Case/BeforeCreate.php @@ -0,0 +1,69 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Modules\Crm\Classes\RecordHooks\Case; + +use Espo\Core\Record\Hook\SaveHook; +use Espo\Entities\User; +use Espo\Modules\Crm\Entities\CaseObj; +use Espo\Modules\Crm\Entities\Contact; +use Espo\ORM\Entity; +use Espo\ORM\EntityManager; + +/** + * @implements SaveHook + * @noinspection PhpUnused + */ +class BeforeCreate implements SaveHook +{ + public function __construct( + private EntityManager $entityManager, + private User $user + ) {} + + public function process(Entity $entity): void + { + if (!$this->user->isPortal()) { + return; + } + + if (!$entity->has('accountId') && $this->user->getContactId()) { + /** @var ?Contact $contact */ + $contact = $this->entityManager->getEntityById(Contact::ENTITY_TYPE, $this->user->getContactId()); + + if ($contact && $contact->getAccount()) { + $entity->set('accountId', $contact->getAccount()->getId()); + } + } + + if (!$entity->has('contactId') && $this->user->getContactId()) { + $entity->set('contactId', $this->user->getContactId()); + } + } +} diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Case.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Case.json index efd30af696..6ed7c31623 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Case.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Case.json @@ -11,7 +11,8 @@ "description": "Description", "inboundEmail": "Group Email Account", "lead": "Lead", - "attachments": "Attachments" + "attachments": "Attachments", + "originalEmail": "Original Email" }, "links": { "inboundEmail": "Group Email Account", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json index c77a4b7ff8..7527766792 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json @@ -69,6 +69,14 @@ "type": "link", "readOnly": true }, + "originalEmail": { + "type": "link", + "notStorable": true, + "entity": "Email", + "customizationDisabled": true, + "layoutAvailabilityList": [], + "directAccessDisabled": true + }, "createdAt": { "type": "datetime", "readOnly": true, diff --git a/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Case.json b/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Case.json index 35d3b8ab91..378bb8f3c4 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Case.json +++ b/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Case.json @@ -7,5 +7,11 @@ "emails": { "linkRequiredForeignAccess": "read" } - } + }, + "beforeCreateHookClassNameList": [ + "Espo\\Modules\\Crm\\Classes\\RecordHooks\\Case\\BeforeCreate" + ], + "afterCreateHookClassNameList": [ + "Espo\\Modules\\Crm\\Classes\\RecordHooks\\Case\\AfterCreate" + ] } diff --git a/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Webhook.json b/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Webhook.json new file mode 100644 index 0000000000..ca78a0a984 --- /dev/null +++ b/application/Espo/Modules/Crm/Resources/metadata/recordDefs/Webhook.json @@ -0,0 +1,17 @@ +{ + "beforeCreateHookClassNameList": [ + "Espo\\Classes\\RecordHooks\\Webhook\\BeforeSave" + ], + "beforeUpdateHookClassNameList": [ + "Espo\\Classes\\RecordHooks\\Webhook\\BeforeSave" + ], + "afterCreateHookClassNameList": [ + "Espo\\Classes\\RecordHooks\\Webhook\\AfterSave" + ], + "afterUpdateHookClassNameList": [ + "Espo\\Classes\\RecordHooks\\Webhook\\AfterSave" + ], + "afterDeleteHookClassNameList": [ + "Espo\\Classes\\RecordHooks\\Webhook\\AfterDelete" + ] +} diff --git a/application/Espo/Modules/Crm/Services/CaseObj.php b/application/Espo/Modules/Crm/Services/CaseObj.php deleted file mode 100644 index 15851f309f..0000000000 --- a/application/Espo/Modules/Crm/Services/CaseObj.php +++ /dev/null @@ -1,89 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Modules\Crm\Services; - -use Espo\Entities\Email; -use Espo\Modules\Crm\Entities\CaseObj as CaseEntity; -use Espo\Modules\Crm\Entities\Contact as ContactEntity; -use Espo\ORM\Entity; -use Espo\Services\Record; - -/** - * @extends Record - */ -class CaseObj extends Record -{ - /** - * @param CaseEntity $entity - */ - public function beforeCreateEntity(Entity $entity, $data) - { - parent::beforeCreateEntity($entity, $data); - - if ($this->user->isPortal()) { - if (!$entity->has('accountId')) { - if ($this->user->getContactId()) { - /** @var ?ContactEntity $contact */ - $contact = $this->entityManager - ->getEntityById(ContactEntity::ENTITY_TYPE, $this->user->getContactId()); - - if ($contact && $contact->getAccount()) { - $entity->set('accountId', $contact->getAccount()->getId()); - } - } - } - - if (!$entity->has('contactId')) { - if ($this->user->getContactId()) { - $entity->set('contactId', $this->user->getContactId()); - } - } - } - } - - public function afterCreateEntity(Entity $entity, $data) - { - parent::afterCreateEntity($entity, $data); - - if (!empty($data->emailId)) { - /** @var ?Email $email */ - $email = $this->entityManager->getEntityById(Email::ENTITY_TYPE, $data->emailId); - - if ($email && !$email->getParentId() && $this->acl->check($email)) { - $email->set([ - 'parentType' => CaseEntity::ENTITY_TYPE, - 'parentId' => $entity->getId(), - ]); - - $this->entityManager->saveEntity($email); - } - } - } -} diff --git a/application/Espo/Services/Webhook.php b/application/Espo/Services/Webhook.php index 7894c11061..2d33739c2a 100644 --- a/application/Espo/Services/Webhook.php +++ b/application/Espo/Services/Webhook.php @@ -31,41 +31,17 @@ namespace Espo\Services; use Espo\Entities\Webhook as WebhookEntity; use Espo\ORM\Entity; -use Espo\Core\Exceptions\Forbidden; -use Espo\Core\Di; -use Espo\Entities\User; use stdClass; /** * @extends Record */ -class Webhook extends Record implements - Di\WebhookManagerAware - +class Webhook extends Record { - use Di\WebhookManagerSetter; - - const WEBHOOK_MAX_COUNT_PER_USER = 50; - - /** - * @var string[] - */ - protected $eventTypeList = [ - 'create', - 'update', - 'delete', - 'fieldUpdate', - ]; - - /** - * @var string[] - */ + /** @var string[] */ protected $onlyAdminAttributeList = ['userId', 'userName']; - - /** - * @var string[] - */ + /** @var string[] */ protected $readOnlyAttributeList = ['secretKey']; public function populateDefaults(Entity $entity, stdClass $data): void @@ -94,165 +70,4 @@ class Webhook extends Record implements parent::filterUpdateInput($data); } - - /** - * @throws Forbidden - */ - protected function beforeCreateEntity(Entity $entity, $data) - { - $this->checkEntityUserIsApi($entity); - $this->processEntityEventData($entity); - - if (!$this->user->isAdmin()) { - $this->checkMaxCount(); - } - } - - /** - * @throws Forbidden - */ - protected function checkMaxCount(): void - { - $maxCount = $this->config->get('webhookMaxCountPerUser', self::WEBHOOK_MAX_COUNT_PER_USER); - - $count = $this->entityManager - ->getRDBRepository(WebhookEntity::ENTITY_TYPE) - ->where([ - 'userId' => $this->user->getId(), - ]) - ->count(); - - if ($maxCount && $count >= $maxCount) { - throw new Forbidden("Webhook number per user exceeded the limit."); - } - } - - /** - * @throws Forbidden - */ - protected function beforeUpdateEntity(Entity $entity, $data) - { - $this->checkEntityUserIsApi($entity); - $this->processEntityEventData($entity); - } - - /** - * @throws Forbidden - */ - protected function checkEntityUserIsApi(Entity $entity): void - { - $userId = $entity->get('userId'); - - if (!$userId) { - return; - } - - /** @var User|null $user */ - $user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId); - - if (!$user || !$user->isApi()) { - throw new Forbidden("User must be an API User."); - } - } - - /** - * @throws Forbidden - */ - protected function processEntityEventData(Entity $entity): void - { - $event = $entity->get('event'); - - if (!$event) { - throw new Forbidden("Event is empty."); - } - - if (!$entity->isNew()) { - if ($entity->isAttributeChanged('event')) { - throw new Forbidden("Event can't be changed."); - } - } - - $arr = explode('.', $event); - - if (count($arr) !== 2 && count($arr) !== 3) { - throw new Forbidden("Not supported event."); - } - - $entityType = $arr[0]; - $type = $arr[1]; - - $entity->set('entityType', $entityType); - $entity->set('type', $type); - - $field = null; - - if (!$entityType) { - throw new Forbidden("Entity Type is empty."); - } - - if (!$this->metadata->get(['scopes', $entityType, 'object'])) { - throw new Forbidden("Entity type is not available for Webhooks."); - } - - if (!$this->entityManager->hasRepository($entityType)) { - throw new Forbidden("Not existing Entity Type."); - } - - if (!$this->acl->checkScope($entityType, 'read')) { - throw new Forbidden("Entity type is forbidden."); - } - - if (!in_array($type, $this->eventTypeList)) { - throw new Forbidden("Not supported event."); - } - - if ($type === 'fieldUpdate') { - if (count($arr) == 3) { - $field = $arr[2]; - } - - $entity->set('field', $field); - - if (!$field) { - throw new Forbidden("Field is empty."); - } - - if (!$this->acl->checkField($entityType, $field)) { - throw new Forbidden("Field is forbidden."); - } - - if (!$this->metadata->get(['entityDefs', $entityType, 'fields', $field])) { - throw new Forbidden("Field does not exist."); - } - } else { - /** @noinspection PhpRedundantOptionalArgumentInspection */ - $entity->set('field', null); - } - } - - protected function afterCreateEntity(Entity $entity, $data) - { - if ($entity->get('isActive')) { - $this->webhookManager->addEvent($entity->get('event')); - } - } - - protected function afterDeleteEntity(Entity $entity) - { - if ($entity->get('isActive')) { - $this->webhookManager->removeEvent($entity->get('event')); - } - } - - protected function afterUpdateEntity(Entity $entity, $data) - { - if (isset($data->isActive)) { - if ($entity->get('isActive')) { - $this->webhookManager->addEvent($entity->get('event')); - } - else { - $this->webhookManager->removeEvent($entity->get('event')); - } - } - } } diff --git a/client/src/views/email/detail.js b/client/src/views/email/detail.js index a9f767e0d5..f777b01696 100644 --- a/client/src/views/email/detail.js +++ b/client/src/views/email/detail.js @@ -291,7 +291,7 @@ class EmailDetailView extends DetailView { } attributes.emailsIds = [this.model.id]; - attributes.emailId = this.model.id; + attributes.originalEmailId = this.model.id; attributes.name = this.model.get('name'); attributes.description = this.model.get('bodyPlain') || '';