Skip to content

Commit

Permalink
DIAM-1726 change notification letters behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Kolomiec committed May 25, 2016
1 parent 3a415e4 commit f828073
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Infrastructure/Message/Zend/ImapMessageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
namespace Diamante\EmailProcessingBundle\Infrastructure\Message\Zend;

use Diamante\DeskBundle\Infrastructure\Notification\NotificationManager;
use Diamante\EmailProcessingBundle\Model\Message;
use Diamante\EmailProcessingBundle\Model\Message\MessageProvider;
use Diamante\EmailProcessingBundle\Model\MessageProcessingException;
Expand Down Expand Up @@ -70,10 +71,11 @@ public function fetchMessagesToProcess()
$messageReference = $this->processMessageReference($headers);
$messageAttachments = $this->processAttachments($imapMessage);
$isFailed = $this->isFailed($headers);
$isSystem = $this->isSystem($headers);
$recipients = $this->processRecipients($headers);

$messages[] = new Message($uniqueMessageId, $messageId, $messageSubject, $messageContent,
$messageFrom, $messageTo, $messageReference, $messageAttachments, $isFailed, $recipients);
$messages[] = new Message($uniqueMessageId, $messageId, $messageSubject, $messageContent, $messageFrom,
$messageTo, $messageReference, $messageAttachments, $isFailed, $isSystem, $recipients);
}
} catch (\Exception $e) {
throw new MessageProcessingException($e->getMessage());
Expand All @@ -91,6 +93,16 @@ private function isFailed($headers)
return $headers->get('xfailedrecipients') ? true : false;
}

/**
* @param \Zend\Mail\Headers $headers
*
* @return bool
*/
private function isSystem($headers)
{
return $headers->get(NotificationManager::SYSTEM_MESSAGE_HEADER) ? true : false;
}

/**
* Retrieves Message Subject
*
Expand Down
16 changes: 16 additions & 0 deletions Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class Message
*/
private $isFailed;

/**
* @var bool
*/
private $isSystem;

/**
* @param $uniqueId
* @param string|null $messageId
Expand All @@ -79,6 +84,7 @@ class Message
* @param string|null $reference
* @param array $attachments
* @param bool $isFailed
* @param bool $isSystem
* @param array $recipients
*/
public function __construct(
Expand All @@ -91,6 +97,7 @@ public function __construct(
$reference = null,
array $attachments = null,
$isFailed = false,
$isSystem = true,
$recipients = null
) {
$this->uniqueId = $uniqueId;
Expand All @@ -102,6 +109,7 @@ public function __construct(
$this->reference = $reference;
$this->attachments = $attachments;
$this->isFailed = $isFailed;
$this->isSystem = $isSystem;
$this->recipients = $recipients;
}

Expand Down Expand Up @@ -185,6 +193,14 @@ public function isFailed()
return $this->isFailed;
}

/**
* @return bool
*/
public function isSystem()
{
return $this->isSystem;
}

/**
* Retrieve emails of recipients
*
Expand Down
2 changes: 1 addition & 1 deletion Model/Service/MessageProcessingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function handle(MessageProvider $provider)
foreach ($strategies as $strategy) {
$this->processingContext->setStrategy($strategy);
try {
if (!$message->isFailed()) {
if (!$message->isFailed() && !$message->isSystem()) {
$this->processingContext->execute($message);
}

Expand Down

0 comments on commit f828073

Please sign in to comment.