diff --git a/src/Lunr/Vortex/JPush/JPushReport.php b/src/Lunr/Vortex/JPush/JPushReport.php index 0271790..8b19436 100644 --- a/src/Lunr/Vortex/JPush/JPushReport.php +++ b/src/Lunr/Vortex/JPush/JPushReport.php @@ -159,12 +159,14 @@ public function get_status(string $endpoint): int */ private function report_error(Requests_Response $response, array &$endpoints): void { - $upstream_msg = NULL; + $upstream_msg = NULL; + $upstream_code = NULL; if (!empty($response->body)) { - $body = json_decode($response->body, TRUE); - $upstream_msg = $body['error']['message'] ?? NULL; + $body = json_decode($response->body, TRUE); + $upstream_msg = $body['error']['message'] ?? NULL; + $upstream_code = $body['error']['code'] ?? NULL; } $status = PushNotificationStatus::ERROR; @@ -172,7 +174,7 @@ private function report_error(Requests_Response $response, array &$endpoints): v switch ($response->status_code) { case 400: - if ($upstream_msg === 'Msgid does not exist') + if ($upstream_code === 3002) { $status = PushNotificationStatus::DEFERRED; } diff --git a/src/Lunr/Vortex/JPush/Tests/JPushReportReportErrorTest.php b/src/Lunr/Vortex/JPush/Tests/JPushReportReportErrorTest.php index 9c1f7cb..440862f 100644 --- a/src/Lunr/Vortex/JPush/Tests/JPushReportReportErrorTest.php +++ b/src/Lunr/Vortex/JPush/Tests/JPushReportReportErrorTest.php @@ -99,10 +99,10 @@ public function testReportEndpointErrorSucceedsWhenResponseIsDeferred(): void $this->logger->expects($this->once()) ->method('warning') - ->with('Getting JPush notification report failed: {error}', [ 'error' => 'Msgid does not exist' ]); + ->with('Getting JPush notification report failed: {error}', [ 'error' => 'Msgid does not exist.' ]); $this->response->status_code = 400; - $this->response->body = '{"error":{"message":"Msgid does not exist"}}'; + $this->response->body = '{"error":{"message":"Msgid does not exist.","code":3002}}'; $method = $this->get_accessible_reflection_method('report_error'); $method->invokeArgs($this->class, [ $this->response, &$endpoints ]);