api endpoints
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Unmark emails as important.
|
||||
*/
|
||||
class DeleteInboxImportant implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$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`.");
|
||||
}
|
||||
|
||||
$this->inboxService->markAsNotImportantIdList($ids);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Retrieves emails from trash.
|
||||
*/
|
||||
class DeleteInboxInTrash implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$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`.");
|
||||
}
|
||||
|
||||
$this->inboxService->retrieveFromTrashIdList($ids);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Unmark emails as read.
|
||||
*/
|
||||
class DeleteInboxRead implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$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`.");
|
||||
}
|
||||
|
||||
$this->inboxService->markAsNotReadIdList($ids);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Entities\Email as EmailEntity;
|
||||
use Espo\Tools\EmailTemplate\InsertField\Service as InsertFieldService;
|
||||
|
||||
class GetInsertFieldData implements Action
|
||||
{
|
||||
public function __construct(
|
||||
private InsertFieldService $service,
|
||||
private Acl $acl
|
||||
) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
if (!$this->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
class GetNotReadCounts implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$data = $this->inboxService->getFoldersNotReadCounts();
|
||||
|
||||
return ResponseComposer::json($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Tools\Attachment\FieldData;
|
||||
use Espo\Tools\Email\Service;
|
||||
|
||||
/**
|
||||
* Copies email attachments.
|
||||
*/
|
||||
class PostAttachmentsCopy implements Action
|
||||
{
|
||||
public function __construct(private Service $service) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$id = $request->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Moves emails to a folder.
|
||||
*/
|
||||
class PostFolder implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$folderId = $request->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Marks emails as important.
|
||||
*/
|
||||
class PostInboxImportant implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$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`.");
|
||||
}
|
||||
|
||||
$this->inboxService->markAsImportantIdList($ids);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Moves emails to trash.
|
||||
*/
|
||||
class PostInboxInTrash implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$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`.");
|
||||
}
|
||||
|
||||
$this->inboxService->moveToTrashIdList($ids);
|
||||
|
||||
return ResponseComposer::json(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Tools\Email\InboxService;
|
||||
|
||||
/**
|
||||
* Marks emails as read.
|
||||
*/
|
||||
class PostInboxRead implements Action
|
||||
{
|
||||
public function __construct(private InboxService $inboxService) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
$data = $request->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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\Email\Api;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Api\Response;
|
||||
use Espo\Core\Api\ResponseComposer;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Mail\SmtpParams;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Tools\Email\SendService;
|
||||
use Espo\Tools\Email\TestSendData;
|
||||
|
||||
/**
|
||||
* Sends test emails.
|
||||
*/
|
||||
class PostSendTest implements Action
|
||||
{
|
||||
public function __construct(
|
||||
private SendService $sendService,
|
||||
private Acl $acl
|
||||
) {}
|
||||
|
||||
public function process(Request $request): Response
|
||||
{
|
||||
if (!$this->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);
|
||||
}
|
||||
}
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'));
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user