Merged in feature/PMC-450 (pull request #6781)
PMC-450 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -20,7 +20,6 @@ use PMLicensedFeatures;
|
|||||||
use ProcessMaker\BusinessModel\ActionsByEmail;
|
use ProcessMaker\BusinessModel\ActionsByEmail;
|
||||||
use ProcessMaker\BusinessModel\EmailServer;
|
use ProcessMaker\BusinessModel\EmailServer;
|
||||||
use ProcessMaker\ChangeLog\ChangeLog;
|
use ProcessMaker\ChangeLog\ChangeLog;
|
||||||
use ProcessMaker\Core\System;
|
|
||||||
use ResultSet;
|
use ResultSet;
|
||||||
use WsBase;
|
use WsBase;
|
||||||
|
|
||||||
@@ -57,13 +56,13 @@ class ResponseReader
|
|||||||
public function actionsByEmailEmailResponse()
|
public function actionsByEmailEmailResponse()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
if (!extension_loaded('imap')) {
|
||||||
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", ['php_imap']) . "\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
if (PMLicensedFeatures
|
if (PMLicensedFeatures
|
||||||
::getSingleton()
|
::getSingleton()
|
||||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
||||||
require_once(PATH_DB . config("system.workspace") . PATH_SEP . "/db.php");
|
|
||||||
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
|
||||||
define('SYS_SKIN', $arraySystemConfiguration['default_skin']);
|
|
||||||
|
|
||||||
$criteriaAbe = new Criteria();
|
$criteriaAbe = new Criteria();
|
||||||
$criteriaAbe->add(AbeConfigurationPeer::ABE_TYPE, "RESPONSE");
|
$criteriaAbe->add(AbeConfigurationPeer::ABE_TYPE, "RESPONSE");
|
||||||
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
|
$resultAbe = AbeConfigurationPeer::doSelectRS($criteriaAbe);
|
||||||
@@ -76,7 +75,7 @@ class ResponseReader
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
$this->channel,
|
$this->channel,
|
||||||
$e->getCode(),
|
$e->getCode() != 0 ? $e->getCode() : 300,
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
$this->case,
|
$this->case,
|
||||||
config("system.workspace"),
|
config("system.workspace"),
|
||||||
@@ -117,7 +116,7 @@ class ResponseReader
|
|||||||
$emailSetup = (!is_null(EmailServerPeer::retrieveByPK($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID']))) ?
|
$emailSetup = (!is_null(EmailServerPeer::retrieveByPK($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID']))) ?
|
||||||
$emailServer->getEmailServer($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID'], true) :
|
$emailServer->getEmailServer($dataAbe['ABE_EMAIL_SERVER_RECEIVER_UID'], true) :
|
||||||
$emailServer->getEmailServerDefault();
|
$emailServer->getEmailServerDefault();
|
||||||
if (empty($emailSetup)) {
|
if (empty($emailSetup) || (empty($emailSetup['MESS_INCOMING_SERVER']) && $emailSetup['MESS_INCOMING_PORT'] == 0)) {
|
||||||
throw (new Exception(G::LoadTranslation('ID_ABE_LOG_CANNOT_READ'), 500));
|
throw (new Exception(G::LoadTranslation('ID_ABE_LOG_CANNOT_READ'), 500));
|
||||||
}
|
}
|
||||||
$mailbox = new Mailbox(
|
$mailbox = new Mailbox(
|
||||||
@@ -130,13 +129,15 @@ class ResponseReader
|
|||||||
$mailsIds = $mailbox->searchMailbox('UNSEEN');
|
$mailsIds = $mailbox->searchMailbox('UNSEEN');
|
||||||
if ($mailsIds) {
|
if ($mailsIds) {
|
||||||
// Get the first message and save its attachment(s) to disk:
|
// Get the first message and save its attachment(s) to disk:
|
||||||
foreach ($mailsIds as $key => $mailsId) {
|
foreach ($mailsIds as $key => $mailId) {
|
||||||
/** @var IncomingMail $mail */
|
/** @var IncomingMail $mail */
|
||||||
$mail = $mailbox->getMail($mailsId);
|
$mail = $mailbox->getMail($mailId, false);
|
||||||
preg_match("/{(.*)}/", $mail->textPlain, $matches);
|
preg_match("/{(.*)}/", $mail->textPlain, $matches);
|
||||||
if ($matches) {
|
if ($matches) {
|
||||||
$dataEmail = G::json_decode(Crypt::decryptString($matches[1]), true);
|
$dataEmail = G::json_decode(Crypt::decryptString($matches[1]), true);
|
||||||
if (config("system.workspace") === $dataEmail['workspace']) {
|
$dataAbeReq = loadAbeRequest($dataEmail['ABE_REQ_UID']);
|
||||||
|
if (config("system.workspace") === $dataEmail['workspace']
|
||||||
|
&& (array_key_exists('ABE_UID', $dataAbeReq) && $dataAbeReq['ABE_UID'] == $dataAbe['ABE_UID'])) {
|
||||||
$this->case = $dataEmail;
|
$this->case = $dataEmail;
|
||||||
try {
|
try {
|
||||||
$appDelegate = new AppDelegation();
|
$appDelegate = new AppDelegation();
|
||||||
@@ -147,6 +148,7 @@ class ResponseReader
|
|||||||
throw (new Exception(G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'), 400));
|
throw (new Exception(G::LoadTranslation('ID_CASE_DELEGATION_ALREADY_CLOSED'), 400));
|
||||||
}
|
}
|
||||||
$this->processABE($this->case, $mail, $dataAbe);
|
$this->processABE($this->case, $mail, $dataAbe);
|
||||||
|
$mailbox->markMailAsRead($mailId);
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
$this->channel,
|
$this->channel,
|
||||||
100, // DEBUG
|
100, // DEBUG
|
||||||
@@ -164,7 +166,7 @@ class ResponseReader
|
|||||||
);
|
);
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
$this->channel,
|
$this->channel,
|
||||||
$e->getCode(),
|
$e->getCode() != 0 ? $e->getCode() : 400,
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
$this->case,
|
$this->case,
|
||||||
config("system.workspace"),
|
config("system.workspace"),
|
||||||
@@ -178,7 +180,7 @@ class ResponseReader
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Bootstrap::registerMonolog(
|
Bootstrap::registerMonolog(
|
||||||
$this->channel,
|
$this->channel,
|
||||||
$e->getCode(),
|
$e->getCode() != 0 ? $e->getCode() : 500,
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
$this->case,
|
$this->case,
|
||||||
config("system.workspace"),
|
config("system.workspace"),
|
||||||
|
|||||||
Reference in New Issue
Block a user