@@ -55,8 +55,6 @@ public function __construct($options = [])
55
55
* @param string $encoding
56
56
*
57
57
* @return MimePart
58
- *
59
- * @noinspection PhpUnused
60
58
*/
61
59
public function buildMessageFromFile (
62
60
MessageInterface $ message ,
@@ -641,24 +639,29 @@ public function buildMdn(MessageInterface $message, $confirmationText = null, $e
641
639
* Sends the AS2 MDN to the partner.
642
640
*
643
641
* @return bool|mixed|ResponseInterface
642
+ * @noinspection PhpDocMissingThrowsInspection
644
643
*/
645
644
public function sendMdn (MessageInterface $ message )
646
645
{
647
- // TODO: cron, queue, new thread
648
646
try {
649
647
$ partner = $ message ->getSender ();
650
648
$ mdn = MimePart::fromString ($ message ->getMdnPayload ());
649
+
651
650
$ options = [
652
651
'body ' => $ mdn ->getBody (),
653
652
'headers ' => $ mdn ->getHeaders (),
654
653
];
654
+
655
655
if ($ partner ->getAuthMethod ()) {
656
656
$ options ['auth ' ] = [$ partner ->getAuthUser (), $ partner ->getAuthPassword (), $ partner ->getAuthMethod ()];
657
657
}
658
+
659
+ /** @noinspection PhpUnhandledExceptionInspection */
658
660
$ response = $ this ->getHttpClient ()->post ($ partner ->getTargetUrl (), $ options );
659
661
if ($ response ->getStatusCode () !== 200 ) {
660
662
throw new \RuntimeException ('Message send failed with error ' );
661
663
}
664
+
662
665
$ this ->getLogger ()->debug ('AS2 MDN has been sent. ' );
663
666
$ message ->setMdnStatus (MessageInterface::MDN_STATUS_SENT );
664
667
@@ -683,6 +686,16 @@ public function getHttpClient()
683
686
return $ this ->httpClient ;
684
687
}
685
688
689
+ // /**
690
+ // * @return $this
691
+ // */
692
+ // public function setHttpClient(ClientInterface $client)
693
+ // {
694
+ // $this->httpClient = $client;
695
+ //
696
+ // return $this;
697
+ // }
698
+
686
699
/**
687
700
* @param string $name
688
701
* @param string $default
0 commit comments