8000 bug #47626 [Notifier] [Expo] Throw exception on error-response from e… · symfony/symfony@ef3df52 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef3df52

Browse files
committed
bug #47626 [Notifier] [Expo] Throw exception on error-response from expo api (sdrewergutland)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Notifier] [Expo] Throw exception on error-response from expo api | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Throw an actual `TransportException`in the case that an error is returned in the response from expo api. Commits ------- 90638ac [Notifier] [Expo] Throw exception on error-response from expo api
2 parents 7dc9d04 + 90638ac commit ef3df52

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public function supports(MessageInterface $message): bool
5050
return $message instanceof PushMessage;
5151
}
5252

53+
/**
54+
* @see https://docs.expo.dev/push-notifications/sending-notifications/#http2-api
55+
*/
5356
protected function doSend(MessageInterface $message): SentMessage
5457
{
5558
if (!$message instanceof PushMessage) {
@@ -91,10 +94,14 @@ protected function doSend(MessageInterface $message): SentMessage
9194
throw new TransportException('Unable to post the Expo message: '.$errorMessage, $response);
9295
}
9396

94-
$success = $response->toArray(false);
97+
$result = $response->toArray(false);
98+
99+
if ('error' === $result['data']['status']) {
100+
throw new TransportException(sprintf('Unable to post the Expo message: "%s" (%s)', $result['data']['message'], $result['data']['details']['error']), $response);
101+
}
95102

96103
$sentMessage = new SentMessage($message, (string) $this);
97-
$sentMessage->setMessageId($success['data']['id']);
104+
$sentMessage->setMessageId($result['data']['id']);
98105

99106
return $sentMessage;
100107
}

0 commit comments

Comments
 (0)
0