diff --git a/application/Espo/Controllers/Email.php b/application/Espo/Controllers/Email.php index 159b638375..224ed66bde 100644 --- a/application/Espo/Controllers/Email.php +++ b/application/Espo/Controllers/Email.php @@ -29,356 +29,7 @@ namespace Espo\Controllers; -use Espo\Core\Acl\Table; -use Espo\Core\Exceptions\BadRequest; -use Espo\Core\Exceptions\Error; -use Espo\Core\Exceptions\Forbidden; -use Espo\Core\Exceptions\NotFound; - use Espo\Core\Controllers\Record; -use Espo\Core\Api\Request; - -use Espo\Core\Mail\SmtpParams; -use Espo\Entities\Email as EmailEntity; -use Espo\Tools\Attachment\FieldData; -use Espo\Tools\Email\SendService; -use Espo\Tools\Email\InboxService as InboxService; - -use Espo\Tools\Email\Service; -use Espo\Tools\Email\TestSendData; -use Espo\Tools\EmailTemplate\InsertField\Service as InsertFieldService; -use stdClass; class Email extends Record -{ - /** - * @throws BadRequest - * @throws Forbidden - * @throws NotFound - */ - public function postActionGetCopiedAttachments(Request $request): stdClass - { - $data = $request->getParsedBody(); - - $id = $data->id ?? null; - $field = $data->field ?? null; - $parentType = $data->parentType ?? null; - $relatedType = $data->relatedType ?? null; - - if (!$id || !$field) { - throw new BadRequest("No `id` or `field`."); - } - - try { - $fieldData = new FieldData( - $field, - $parentType, - $relatedType - ); - } - catch (Error $e) { - throw new BadRequest($e->getMessage()); - } - - $list = $this->injectableFactory - ->create(Service::class) - ->copyAttachments($id, $fieldData); - - $ids = array_map( - fn ($item) => $item->getId(), - $list - ); - - $names = (object) []; - - foreach ($list as $item) { - $names->{$item->getId()} = $item->getName(); - } - - return (object) [ - 'ids' => $ids, - 'names' => $names, - ]; - } - - /** - * @throws Forbidden - * @throws NotFound - * @throws Error - * @throws BadRequest - */ - public function postActionSendTestEmail(Request $request): bool - { - if (!$this->acl->checkScope(EmailEntity::ENTITY_TYPE)) { - throw new Forbidden(); - } - - $data = $request->getParsedBody(); - - $type = $data->type ?? null; - $id = $data->id ?? null; - $server = $data->server ?? null; - $port = $data->port ?? null; - $username = $data->username ?? null; - $password = $data->password ?? null; - $auth = $data->auth ?? null; - $authMechanism = $data->authMechanism ?? null; - $security = $data->security ?? null; - $userId = $data->userId ?? null; - $fromAddress = $data->fromAddress ?? null; - $fromName = $data->fromName ?? null; - $emailAddress = $data->emailAddress ?? null; - - if (!is_string($server)) { - throw new BadRequest("`server`"); - } - - - if (!is_int($port)) { - throw new BadRequest("`port`."); - } - - if (!is_string($emailAddress)) { - throw new BadRequest("`emailAddress`."); - } - - $smtpParams = SmtpParams - ::create($server, $port) - ->withSecurity($security) - ->withFromName($fromName) - ->withFromAddress($fromAddress) - ->withAuth($auth); - - if ($auth) { - $smtpParams = $smtpParams - ->withUsername($username) - ->withPassword($password) - ->withAuthMechanism($authMechanism); - } - - $data = new TestSendData($emailAddress, $type, $id, $userId); - - $this->getSendService()->sendTestEmail($smtpParams, $data); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionMarkAsRead(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->markAsReadIdList($idList); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionMarkAsNotRead(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->markAsNotReadIdList($idList); - - return true; - } - - public function postActionMarkAllAsRead(): bool - { - $this->getInboxService()->markAllAsRead(); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionMarkAsImportant(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->markAsImportantIdList($idList); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionMarkAsNotImportant(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->markAsNotImportantIdList($idList); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionMoveToTrash(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->moveToTrashIdList($idList); - - return true; - } - - /** - * @throws BadRequest - */ - public function postActionRetrieveFromTrash(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else { - if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - } - - $this->getInboxService()->retrieveFromTrashIdList($idList); - - return true; - } - - public function getActionGetFoldersNotReadCounts(): stdClass - { - return (object) $this->getInboxService()->getFoldersNotReadCounts(); - } - - /** - * @throws BadRequest - * @throws Forbidden - * @throws NotFound - */ - public function postActionMoveToFolder(Request $request): bool - { - $data = $request->getParsedBody(); - - if (!empty($data->ids)) { - $idList = $data->ids; - } - else if (!empty($data->id)) { - $idList = [$data->id]; - } - else { - throw new BadRequest(); - } - - if (empty($data->folderId)) { - throw new BadRequest(); - } - - if (count($idList) === 1) { - $this->getInboxService()->moveToFolder($idList[0], $data->folderId); - - return true; - - } - - $this->getInboxService()->moveToFolderIdList($idList, $data->folderId); - - return true; - } - - /** - * @throws Forbidden - */ - public function getActionGetInsertFieldData(Request $request): stdClass - { - if (!$this->acl->checkScope(EmailEntity::ENTITY_TYPE, Table::ACTION_CREATE)) { - throw new Forbidden(); - } - - return $this->injectableFactory - ->create(InsertFieldService::class) - ->getData( - $request->getQueryParam('parentType'), - $request->getQueryParam('parentId'), - $request->getQueryParam('to') - ); - } - - private function getInboxService(): InboxService - { - return $this->injectableFactory->create(InboxService::class); - } - - private function getSendService(): SendService - { - return $this->injectableFactory->create(SendService::class); - } -} +{} diff --git a/application/Espo/Resources/routes.json b/application/Espo/Resources/routes.json index 9df9bd56f9..ccb29aac7c 100644 --- a/application/Espo/Resources/routes.json +++ b/application/Espo/Resources/routes.json @@ -305,6 +305,61 @@ "method": "post", "actionClassName": "Espo\\Tools\\Attachment\\Api\\PostCopy" }, + { + "route": "/Email/:id/attachments/copy", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostAttachmentsCopy" + }, + { + "route": "/Email/sendTest", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostSendTest" + }, + { + "route": "/Email/inbox/read", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostInboxRead" + }, + { + "route": "/Email/inbox/read", + "method": "delete", + "actionClassName": "Espo\\Tools\\Email\\Api\\DeleteInboxRead" + }, + { + "route": "/Email/inbox/important", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostInboxImportant" + }, + { + "route": "/Email/inbox/important", + "method": "delete", + "actionClassName": "Espo\\Tools\\Email\\Api\\DeleteInboxImportant" + }, + { + "route": "/Email/inbox/inTrash", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostInboxInTrash" + }, + { + "route": "/Email/inbox/inTrash", + "method": "delete", + "actionClassName": "Espo\\Tools\\Email\\Api\\DeleteInboxInTrash" + }, + { + "route": "/Email/inbox/folders/:folderId", + "method": "post", + "actionClassName": "Espo\\Tools\\Email\\Api\\PostFolder" + }, + { + "route": "/Email/inbox/notReadCounts", + "method": "get", + "actionClassName": "Espo\\Tools\\Email\\Api\\GetNotReadCounts" + }, + { + "route": "/Email/insertFieldData", + "method": "get", + "actionClassName": "Espo\\Tools\\Email\\Api\\GetInsertFieldData" + }, { "route": "/Oidc/authorizationData", "method": "get", diff --git a/application/Espo/Tools/Email/Api/DeleteInboxImportant.php b/application/Espo/Tools/Email/Api/DeleteInboxImportant.php new file mode 100644 index 0000000000..a046a48e67 --- /dev/null +++ b/application/Espo/Tools/Email/Api/DeleteInboxImportant.php @@ -0,0 +1,65 @@ +getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->markAsNotImportantIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/DeleteInboxInTrash.php b/application/Espo/Tools/Email/Api/DeleteInboxInTrash.php new file mode 100644 index 0000000000..e65dd45d12 --- /dev/null +++ b/application/Espo/Tools/Email/Api/DeleteInboxInTrash.php @@ -0,0 +1,65 @@ +getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->retrieveFromTrashIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/DeleteInboxRead.php b/application/Espo/Tools/Email/Api/DeleteInboxRead.php new file mode 100644 index 0000000000..e0e6d1ea90 --- /dev/null +++ b/application/Espo/Tools/Email/Api/DeleteInboxRead.php @@ -0,0 +1,65 @@ +getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->markAsNotReadIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/GetInsertFieldData.php b/application/Espo/Tools/Email/Api/GetInsertFieldData.php new file mode 100644 index 0000000000..80da3ff110 --- /dev/null +++ b/application/Espo/Tools/Email/Api/GetInsertFieldData.php @@ -0,0 +1,63 @@ +acl->checkScope(EmailEntity::ENTITY_TYPE, Table::ACTION_CREATE)) { + throw new Forbidden(); + } + + $data = $this->service->getData( + $request->getQueryParam('parentType'), + $request->getQueryParam('parentId'), + $request->getQueryParam('to') + ); + + return ResponseComposer::json($data); + } +} diff --git a/application/Espo/Tools/Email/Api/GetNotReadCounts.php b/application/Espo/Tools/Email/Api/GetNotReadCounts.php new file mode 100644 index 0000000000..2ee5d1900e --- /dev/null +++ b/application/Espo/Tools/Email/Api/GetNotReadCounts.php @@ -0,0 +1,48 @@ +inboxService->getFoldersNotReadCounts(); + + return ResponseComposer::json($data); + } +} diff --git a/application/Espo/Tools/Email/Api/PostAttachmentsCopy.php b/application/Espo/Tools/Email/Api/PostAttachmentsCopy.php new file mode 100644 index 0000000000..179ea06945 --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostAttachmentsCopy.php @@ -0,0 +1,88 @@ +getRouteParam('id'); + + if (!$id) { + throw new BadRequest(); + } + + $data = $request->getParsedBody(); + + $field = $data->field ?? null; + $parentType = $data->parentType ?? null; + $relatedType = $data->relatedType ?? null; + + if (!$field) { + throw new BadRequest("No `field`."); + } + + try { + $fieldData = new FieldData($field, $parentType, $relatedType); + } + catch (Error $e) { + throw new BadRequest($e->getMessage()); + } + + $list = $this->service->copyAttachments($id, $fieldData); + + $ids = array_map(fn ($item) => $item->getId(), $list); + + $names = (object) []; + + foreach ($list as $item) { + $names->{$item->getId()} = $item->getName(); + } + + return ResponseComposer::json([ + 'ids' => $ids, + 'names' => $names, + ]); + } +} diff --git a/application/Espo/Tools/Email/Api/PostFolder.php b/application/Espo/Tools/Email/Api/PostFolder.php new file mode 100644 index 0000000000..761b65cbc9 --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostFolder.php @@ -0,0 +1,75 @@ +getRouteParam('folderId'); + + if (!$folderId) { + throw new BadRequest(); + } + + $data = $request->getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + if (count($ids) === 1) { + $this->inboxService->moveToFolder($ids[0], $folderId); + } + + $this->inboxService->moveToFolderIdList($ids, $folderId); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/PostInboxImportant.php b/application/Espo/Tools/Email/Api/PostInboxImportant.php new file mode 100644 index 0000000000..cb07caf62a --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostInboxImportant.php @@ -0,0 +1,65 @@ +getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->markAsImportantIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/PostInboxInTrash.php b/application/Espo/Tools/Email/Api/PostInboxInTrash.php new file mode 100644 index 0000000000..fb204e267d --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostInboxInTrash.php @@ -0,0 +1,65 @@ +getParsedBody(); + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->moveToTrashIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/PostInboxRead.php b/application/Espo/Tools/Email/Api/PostInboxRead.php new file mode 100644 index 0000000000..fc67e59b3b --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostInboxRead.php @@ -0,0 +1,71 @@ +getParsedBody(); + + if (!empty($data->all)) { + $this->inboxService->markAllAsRead(); + + return ResponseComposer::json(true); + } + + $ids = $data->ids ?? null; + $id = $data->id ?? null; + + if ($ids === null && is_string($id)) { + $ids = [$id]; + } + + if (!is_array($ids)) { + throw new BadRequest("No `ids`."); + } + + $this->inboxService->markAsReadIdList($ids); + + return ResponseComposer::json(true); + } +} diff --git a/application/Espo/Tools/Email/Api/PostSendTest.php b/application/Espo/Tools/Email/Api/PostSendTest.php new file mode 100644 index 0000000000..5ffd1017ce --- /dev/null +++ b/application/Espo/Tools/Email/Api/PostSendTest.php @@ -0,0 +1,108 @@ +acl->checkScope(Email::ENTITY_TYPE)) { + throw new Forbidden(); + } + + $data = $request->getParsedBody(); + + $type = $data->type ?? null; + $id = $data->id ?? null; + $server = $data->server ?? null; + $port = $data->port ?? null; + $username = $data->username ?? null; + $password = $data->password ?? null; + $auth = $data->auth ?? null; + $authMechanism = $data->authMechanism ?? null; + $security = $data->security ?? null; + $userId = $data->userId ?? null; + $fromAddress = $data->fromAddress ?? null; + $fromName = $data->fromName ?? null; + $emailAddress = $data->emailAddress ?? null; + + if (!is_string($server)) { + throw new BadRequest("No `server`"); + } + + if (!is_int($port)) { + throw new BadRequest("No or bad `port`."); + } + + if (!is_string($emailAddress)) { + throw new BadRequest("No `emailAddress`."); + } + + $smtpParams = SmtpParams + ::create($server, $port) + ->withSecurity($security) + ->withFromName($fromName) + ->withFromAddress($fromAddress) + ->withAuth($auth); + + if ($auth) { + $smtpParams = $smtpParams + ->withUsername($username) + ->withPassword($password) + ->withAuthMechanism($authMechanism); + } + + $data = new TestSendData($emailAddress, $type, $id, $userId); + + $this->sendService->sendTestEmail($smtpParams, $data); + + return ResponseComposer::json(true); + } +} diff --git a/client/src/views/email-folder/list-side.js b/client/src/views/email-folder/list-side.js index d05b81ff99..308c53f962 100644 --- a/client/src/views/email-folder/list-side.js +++ b/client/src/views/email-folder/list-side.js @@ -238,7 +238,7 @@ define('views/email-folder/list-side', ['view'], function (Dep) { this.countsIsBeingLoaded = true; - this.ajaxGetRequest('Email/action/getFoldersNotReadCounts').then(data => { + this.ajaxGetRequest('Email/inbox/notReadCounts').then(data => { this.countsData = data; if (this.isRendered()) { diff --git a/client/src/views/email/detail.js b/client/src/views/email/detail.js index 7494188cd6..39720cce54 100644 --- a/client/src/views/email/detail.js +++ b/client/src/views/email/detail.js @@ -304,8 +304,7 @@ define('views/email/detail', ['views/detail', 'email-helper'], function (Dep, Em return; } - this.ajaxPostRequest('Email/action/getCopiedAttachments', { - id: this.model.id, + this.ajaxPostRequest(`Email/${this.model.id}/attachments/copy`, { parentType: 'Case', field: 'attachments', }).then(data => { diff --git a/client/src/views/email/modals/insert-field.js b/client/src/views/email/modals/insert-field.js index d114f4f32f..6072616070 100644 --- a/client/src/views/email/modals/insert-field.js +++ b/client/src/views/email/modals/insert-field.js @@ -77,7 +77,7 @@ define('views/email/modals/insert-field', ['views/modal', 'field-language'], fun this.wait( Espo.Ajax - .getRequest('Email/action/getInsertFieldData', { + .getRequest('Email/insertFieldData', { parentId: this.options.parentId, parentType: this.options.parentType, to: this.options.to, diff --git a/client/src/views/email/record/detail.js b/client/src/views/email/record/detail.js index c5ea29e346..b024612418 100644 --- a/client/src/views/email/record/detail.js +++ b/client/src/views/email/record/detail.js @@ -252,25 +252,19 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) { }, actionMarkAsImportant: function () { - Espo.Ajax.postRequest('Email/action/markAsImportant', { - id: this.model.id - }); + Espo.Ajax.postRequest('Email/inbox/important', {id: this.model.id}); this.model.set('isImportant', true); }, actionMarkAsNotImportant: function () { - Espo.Ajax.postRequest('Email/action/markAsNotImportant', { - id: this.model.id - }); + Espo.Ajax.deleteRequest('Email/inbox/important', {id: this.model.id}); this.model.set('isImportant', false); }, actionMoveToTrash: function () { - Espo.Ajax.postRequest('Email/action/moveToTrash', { - id: this.model.id - }).then(() => { + Espo.Ajax.postRequest('Email/inbox/inTrash', {id: this.model.id}).then(() => { Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email')); }); @@ -282,9 +276,7 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) { }, actionRetrieveFromTrash: function () { - Espo.Ajax.postRequest('Email/action/retrieveFromTrash', { - id: this.model.id, - }).then(() => { + Espo.Ajax.deleteRequest('Email/inbox/inTrash', {id: this.model.id}).then(() => { Espo.Ui.warning(this.translate('Retrieved from Trash', 'labels', 'Email')); }); @@ -299,21 +291,19 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) { this.createView('dialog', 'views/email-folder/modals/select-folder', {}, (view) => { view.render(); - this.listenToOnce(view, 'select', (folderId, folderName) => { + this.listenToOnce(view, 'select', folderId => { this.clearView('dialog'); - this.ajaxPostRequest('Email/action/moveToFolder', { - id: this.model.id, - folderId: folderId, - }).then(() => { - if (folderId === 'inbox') { - folderId = null; - } + this.ajaxPostRequest(`Email/inbox/folders/${folderId}`, {id: this.model.id}) + .then(() => { + if (folderId === 'inbox') { + folderId = null; + } - this.model.set('folderId', folderId); + this.model.set('folderId', folderId); - Espo.Ui.success(this.translate('Done')); - }); + Espo.Ui.success(this.translate('Done')); + }); }); }); }, diff --git a/client/src/views/email/record/list.js b/client/src/views/email/record/list.js index 5f26e116be..570415308b 100644 --- a/client/src/views/email/record/list.js +++ b/client/src/views/email/record/list.js @@ -90,8 +90,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], ids.push(this.checkedList[i]); } - Espo.Ajax - .postRequest('Email/action/markAsRead', {ids: ids}); + Espo.Ajax.postRequest('Email/inbox/read', {ids: ids}); ids.forEach(id => { let model = this.collection.get(id); @@ -109,8 +108,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], ids.push(this.checkedList[i]); } - Espo.Ajax - .postRequest('Email/action/markAsNotRead', {ids: ids}); + Espo.Ajax.deleteRequest('Email/inbox/read', {ids: ids}); ids.forEach(id => { let model = this.collection.get(id); @@ -128,8 +126,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], ids.push(this.checkedList[i]); } - Espo.Ajax - .postRequest('Email/action/markAsImportant', {ids: ids}); + Espo.Ajax.postRequest('Email/inbox/important', {ids: ids}); ids.forEach(id => { let model = this.collection.get(id); @@ -147,8 +144,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], ids.push(this.checkedList[i]); } - Espo.Ajax - .postRequest('Email/action/markAsNotImportant', {ids: ids}); + Espo.Ajax.deleteRequest('Email/inbox/important', {ids: ids}); ids.forEach(id => { let model = this.collection.get(id); @@ -167,7 +163,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], } Espo.Ajax - .postRequest('Email/action/moveToTrash', {ids: ids}) + .postRequest('Email/inbox/inTrash', {ids: ids}) .then(() => { Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email')); }); @@ -189,7 +185,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], } Espo.Ajax - .postRequest('Email/action/retrieveFromTrash', {ids: ids}) + .deleteRequest('Email/inbox/inTrash', {ids: ids}) .then(() => { Espo.Ui.success(this.translate('Done')); }); @@ -262,10 +258,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], let id = data.id; - Espo.Ajax - .postRequest('Email/action/markAsImportant', { - id: id, - }); + Espo.Ajax.postRequest('Email/inbox/important', {id: id}); let model = this.collection.get(id); @@ -279,8 +272,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], let id = data.id; - Espo.Ajax - .postRequest('Email/action/markAsNotImportant', {id: id}); + Espo.Ajax.deleteRequest('Email/inbox/important', {id: id}); let model = this.collection.get(id); @@ -290,8 +282,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], }, actionMarkAllAsRead: function () { - Espo.Ajax - .postRequest('Email/action/markAllAsRead'); + Espo.Ajax.postRequest('Email/inbox/read', {all: true}); this.collection.forEach(model => { model.set('isRead', true); @@ -306,9 +297,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], Espo.Ui.notify(' ... '); Espo.Ajax - .postRequest('Email/action/moveToTrash', { - id: id - }) + .postRequest('Email/inbox/inTrash', {id: id}) .then(() => { Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email')); @@ -334,7 +323,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], * @return {Promise} */ retrieveFromTrash: function (id) { - return Espo.Ajax.postRequest('Email/action/retrieveFromTrash', {id: id}); + return Espo.Ajax.deleteRequest('Email/inbox/inTrash', {id: id}); }, massRetrieveFromTrashMoveToFolder: function (folderId) { @@ -345,17 +334,14 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], } Espo.Ajax - .postRequest('Email/action/retrieveFromTrash', {ids: ids}) + .deleteRequest('Email/inbox/inTrash', {ids: ids}) .then(() => { ids.forEach(id => { this.collection.trigger('retrieving-from-trash', id, this.collection.get(id)); }); return Espo.Ajax - .postRequest('Email/action/moveToFolder', { - ids: ids, - folderId: folderId, - }) + .postRequest(`Email/inbox/folders/${folderId}`, {ids: ids}) .then(() => { Espo.Ui.success(this.translate('Done')); }) @@ -388,11 +374,7 @@ define('views/email/record/list', ['views/record/list', 'helpers/mass-action'], * @return {Promise} */ moveToFolder: function (id, folderId) { - return Espo.Ajax - .postRequest('Email/action/moveToFolder', { - id: id, - folderId: folderId, - }); + return Espo.Ajax.postRequest(`Email/inbox/folders/${folderId}`, {id: id}); }, actionMoveToFolder: function (data) { diff --git a/client/src/views/outbound-email/fields/test-send.js b/client/src/views/outbound-email/fields/test-send.js index b08524ae0f..c3739b8eaa 100644 --- a/client/src/views/outbound-email/fields/test-send.js +++ b/client/src/views/outbound-email/fields/test-send.js @@ -92,7 +92,7 @@ define('views/outbound-email/fields/test-send', 'views/fields/base', function (D view.close(); - Espo.Ajax.postRequest('Email/action/sendTestEmail', data) + Espo.Ajax.postRequest('Email/sendTest', data) .then(() => { this.$el.find('button').removeClass('disabled');