From 41b3d84e9dd359fdf0ad26671df5a1558ba26d05 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 12 Jun 2024 21:32:52 +0200 Subject: [PATCH] fix error handling of register request with unknown transport --- lib/Dav/SubscriptionManagementPlugin.php | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/Dav/SubscriptionManagementPlugin.php b/lib/Dav/SubscriptionManagementPlugin.php index f15dd62..4d9a34a 100644 --- a/lib/Dav/SubscriptionManagementPlugin.php +++ b/lib/Dav/SubscriptionManagementPlugin.php @@ -123,27 +123,26 @@ class SubscriptionManagementPlugin extends ServerPlugin { $transport = $this->transportManager->getTransport($subscriptionType); - if($transport === null) { + if(!is_null($transport)) { + [ + 'success' => $registerSuccess, + 'error' => $registerError, + 'responseStatus' => $responseStatus, + 'response' => $responseContent, + 'unsubscribeLink' => $unsubscribeLink, + 'data' => $data + ] = $transport->registerSubscription($subscriptionOptions); + + $responseStatus = $responseStatus ?? Http::STATUS_CREATED; + $data = $data ?? False; + + if(!$registerSuccess) { + $errors[] = $registerError; + } + } else { $errors[] = $subscriptionType . " transport does not exist"; } - [ - 'success' => $registerSuccess, - 'error' => $registerError, - 'responseStatus' => $responseStatus, - 'response' => $responseContent, - 'unsubscribeLink' => $unsubscribeLink, - 'data' => $data - ] = $transport->registerSubscription($subscriptionOptions); - - $responseStatus = $responseStatus ?? Http::STATUS_CREATED; - $data = $data ?? False; - - - if(!$registerSuccess) { - $errors[] = $registerError; - } - if(sizeof($errors) == 0) { $response->setStatus($responseStatus); @@ -179,4 +178,4 @@ class SubscriptionManagementPlugin extends ServerPlugin { return false; } } -} \ No newline at end of file +}