Added Pushy Messaging Adapter - #149
Conversation
|
Thanks for contributing! This repository is a read-only mirror; development for this library happens in |
Greptile SummaryAdds a Pushy push-notification adapter.
Confidence Score: 3/5The PR should not merge until Pushy reports transport, redirect, and server failures for every attempted recipient. The request helper returns status code 0 and non-2xx HTTP responses normally, but the new adapter handles only 2xx and 4xx statuses, causing other failures to return an empty result set and bypass telemetry. Files Needing Attention: src/Utopia/Messaging/Adapter/Push/Pushy.php Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/Utopia/Messaging/Adapter/Push/Pushy.php:54-68
**Non-client failures lose results**
When Pushy returns a redirect or server error, or the HTTP client reports a transport failure with status code 0, neither branch adds recipient results. This returns `deliveredTo=0` with an empty result set, discards the underlying error, and prevents failure telemetry from being recorded for the batch.
Reviews (1): Last reviewed commit: "Added Pushy Messaging Adapter" | Re-trigger Greptile |
| if ($statusCode >= 200 && $statusCode < 300) { | ||
| $response->setDeliveredTo(\count($message->getTo())); | ||
| foreach ($message->getTo() as $to) { | ||
| $response->addResult($to); | ||
| } | ||
| } elseif ($statusCode >= 400 && $statusCode < 500) { | ||
| $error = ''; | ||
| if (\is_array($responseBody) && isset($responseBody['error'])) { | ||
| $error = $responseBody['error']; | ||
| } elseif (\is_string($responseBody)) { | ||
| $error = $responseBody; | ||
| } | ||
|
|
||
| foreach ($message->getTo() as $to) { | ||
| $response->addResult($to, $error ?: 'Unknown error'); |
There was a problem hiding this comment.
Non-client failures lose results
When Pushy returns a redirect or server error, or the HTTP client reports a transport failure with status code 0, neither branch adds recipient results. This returns deliveredTo=0 with an empty result set, discards the underlying error, and prevents failure telemetry from being recorded for the batch.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Utopia/Messaging/Adapter/Push/Pushy.php
Line: 54-68
Comment:
**Non-client failures lose results**
When Pushy returns a redirect or server error, or the HTTP client reports a transport failure with status code 0, neither branch adds recipient results. This returns `deliveredTo=0` with an empty result set, discards the underlying error, and prevents failure telemetry from being recorded for the batch.
How can I resolve this? If you propose a fix, please make it concise.
Rebased on latest main. Updated adapter to current conventions.