Skip to content

Commit

Permalink
defensive coding when using cypher to encrypt mail messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydspaniard committed Aug 25, 2016
1 parent 3a79e64 commit 1970853
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Queue/MailQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Da\Mailer\Queue;

use Da\Mailer\Model\MailMessage;
use Da\Mailer\Queue\Backend\AbstractQueueStoreConnection;
use Da\Mailer\Queue\Backend\MailJobInterface;
use Da\Mailer\Queue\Backend\QueueStoreAdapterInterface;
Expand Down Expand Up @@ -56,8 +57,9 @@ public function getCypher()
*/
public function enqueue(MailJobInterface $mailJob)
{
if (null !== $this->getCypher()) {
$mailJob->setMessage($this->getCypher()->encodeMailMessage($mailJob->getMessage()));
$message = $mailJob->getMessage();
if (null !== $this->getCypher() && $message instanceof MailMessage) {
$mailJob->setMessage($this->getCypher()->encodeMailMessage($message));
}

return $this->adapter->enqueue($mailJob);
Expand Down

0 comments on commit 1970853

Please sign in to comment.