Updates for postmark webhook processing

This commit is contained in:
David Bomba 2024-03-29 07:43:19 +11:00
parent bb706a654a
commit d00730bc8b

View File

@ -359,6 +359,20 @@ class ProcessPostmarkWebhook implements ShouldQueue
$postmark = new PostmarkClient($postmark_secret); $postmark = new PostmarkClient($postmark_secret);
$messageDetail = $postmark->getOutboundMessageDetails($message_id); $messageDetail = $postmark->getOutboundMessageDetails($message_id);
try {
$messageDetail = $postmark->getOutboundMessageDetails($message_id);
} catch(\Exception $e) {
$postmark_secret = config('services.postmark-outlook.token');
$postmark = new PostmarkClient($postmark_secret);
$messageDetail = $postmark->getOutboundMessageDetails($message_id);
}
return $messageDetail; return $messageDetail;
} }
@ -391,7 +405,17 @@ class ProcessPostmarkWebhook implements ShouldQueue
$postmark_secret = !empty($this->company->settings->postmark_secret) ? $this->company->settings->postmark_secret : config('services.postmark.token'); $postmark_secret = !empty($this->company->settings->postmark_secret) ? $this->company->settings->postmark_secret : config('services.postmark.token');
$postmark = new PostmarkClient($postmark_secret); $postmark = new PostmarkClient($postmark_secret);
$messageDetail = $postmark->getOutboundMessageDetails($this->request['MessageID']);
try {
$messageDetail = $postmark->getOutboundMessageDetails($this->request['MessageID']);
}
catch(\Exception $e){
$postmark_secret = config('services.postmark-outlook.token');
$postmark = new PostmarkClient($postmark_secret);
$messageDetail = $postmark->getOutboundMessageDetails($this->request['MessageID']);
}
$recipients = collect($messageDetail['recipients'])->flatten()->implode(','); $recipients = collect($messageDetail['recipients'])->flatten()->implode(',');
$subject = $messageDetail->subject ?? ''; $subject = $messageDetail->subject ?? '';