From 0f6ede941d700846c9752b920e6fbdaded29480c Mon Sep 17 00:00:00 2001 From: chuccv Date: Tue, 3 Dec 2024 11:49:10 +0700 Subject: [PATCH] fix: Dev mode & clean code --- Mail/Transport.php | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Mail/Transport.php b/Mail/Transport.php index e3a8761..837b301 100644 --- a/Mail/Transport.php +++ b/Mail/Transport.php @@ -97,58 +97,58 @@ public function __construct( } /** + * Around send message + * * @param TransportInterface $subject * @param Closure $proceed * * @throws MailException * @throws Zend_Exception */ - public function aroundSendMessage( - TransportInterface $subject, - Closure $proceed - ) { + public function aroundSendMessage(TransportInterface $subject, Closure $proceed) + { $this->_storeId = $this->registry->registry('mp_smtp_store_id'); - $message = $this->getMessage($subject); - - if ($this->resourceMail->isModuleEnable($this->_storeId) && $message) { - if ($this->helper->versionCompare('2.2.8')) { - $message = Message::fromString($message->getRawMessage())->setEncoding('utf-8'); - } + if (!$this->resourceMail->isModuleEnable($this->_storeId)) { + $proceed(); - if (!$this->validateBlacklist($message)) { - $message = $this->resourceMail->processMessage($message, $this->_storeId); - $transport = $this->resourceMail->getTransport($this->_storeId); - try { - if (!$this->resourceMail->isDeveloperMode($this->_storeId)) { - if ($this->helper->versionCompare('2.3.3')) { - $message->getHeaders()->removeHeader("Content-Disposition"); - } - $transport->send($message); + return; + } + $message = $this->getMessage($subject); + if ($this->helper->versionCompare('2.2.8')) { + $message = Message::fromString($message->getRawMessage())->setEncoding('utf-8'); + } + if (!$this->validateBlacklist($message)) { + $message = $this->resourceMail->processMessage($message, $this->_storeId); + try { + if (!$this->resourceMail->isDeveloperMode($this->_storeId)) { + if ($this->helper->versionCompare('2.3.3')) { + $message->getHeaders()->removeHeader("Content-Disposition"); + } + $transport = $this->resourceMail->getTransport($this->_storeId); + $transport->send($message); - if ($this->helper->versionCompare('2.2.8')) { - $messageTmp = $this->getMessage($subject); - if ($messageTmp && is_object($messageTmp)) { - $body = $messageTmp->getBody(); - if (is_object($body) && $body->isMultiPart()) { - $message->setBody($body->getPartContent("0")); - } + if ($this->helper->versionCompare('2.2.8')) { + $messageTmp = $this->getMessage($subject); + if ($messageTmp && is_object($messageTmp)) { + $body = $messageTmp->getBody(); + if (is_object($body) && $body->isMultiPart()) { + $message->setBody($body->getPartContent("0")); } } - - $this->emailLog($message); } - } catch (Exception $e) { - $this->emailLog($message, false); - throw new MailException(new Phrase($e->getMessage()), $e); } + $this->emailLog($message); + } catch (Exception $e) { + $this->emailLog($message, false); + throw new MailException(new Phrase($e->getMessage()), $e); } - } else { - $proceed(); } } /** - * @param $transport + * Get message + * + * @param TransportInterface $transport * * @return mixed|null */