Skip to content

Commit c4c6a23

Browse files
committed
some refactory
1 parent c5d07a2 commit c4c6a23

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Management.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public function __construct($options = [])
5555
* @param string $encoding
5656
*
5757
* @return MimePart
58-
*
59-
* @noinspection PhpUnused
6058
*/
6159
public function buildMessageFromFile(
6260
MessageInterface $message,
@@ -641,24 +639,29 @@ public function buildMdn(MessageInterface $message, $confirmationText = null, $e
641639
* Sends the AS2 MDN to the partner.
642640
*
643641
* @return bool|mixed|ResponseInterface
642+
* @noinspection PhpDocMissingThrowsInspection
644643
*/
645644
public function sendMdn(MessageInterface $message)
646645
{
647-
// TODO: cron, queue, new thread
648646
try {
649647
$partner = $message->getSender();
650648
$mdn = MimePart::fromString($message->getMdnPayload());
649+
651650
$options = [
652651
'body' => $mdn->getBody(),
653652
'headers' => $mdn->getHeaders(),
654653
];
654+
655655
if ($partner->getAuthMethod()) {
656656
$options['auth'] = [$partner->getAuthUser(), $partner->getAuthPassword(), $partner->getAuthMethod()];
657657
}
658+
659+
/** @noinspection PhpUnhandledExceptionInspection */
658660
$response = $this->getHttpClient()->post($partner->getTargetUrl(), $options);
659661
if ($response->getStatusCode() !== 200) {
660662
throw new \RuntimeException('Message send failed with error');
661663
}
664+
662665
$this->getLogger()->debug('AS2 MDN has been sent.');
663666
$message->setMdnStatus(MessageInterface::MDN_STATUS_SENT);
664667

@@ -683,6 +686,16 @@ public function getHttpClient()
683686
return $this->httpClient;
684687
}
685688

689+
// /**
690+
// * @return $this
691+
// */
692+
// public function setHttpClient(ClientInterface $client)
693+
// {
694+
// $this->httpClient = $client;
695+
//
696+
// return $this;
697+
// }
698+
686699
/**
687700
* @param string $name
688701
* @param string $default

src/Server.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public function execute(ServerRequestInterface $request = null)
172172
$messageId
173173
)
174174
);
175+
176+
// TODO: async, event, queue, etc.
175177
$this->manager->sendMdn($message);
176178
}
177179
}

0 commit comments

Comments
 (0)