feat: Add OneSignal Push Notification Adapter (#7726)#5
Open
deepshekhardas wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/Messaging/Adapter/Push/OneSignalTest.php">
<violation number="1" location="tests/Messaging/Adapter/Push/OneSignalTest.php:13">
P1: Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any `ONESIGNAL_*` env vars.</violation>
</file>
<file name="src/Utopia/Messaging/Adapter/Push/OneSignal.php">
<violation number="1" location="src/Utopia/Messaging/Adapter/Push/OneSignal.php:87">
P2: `deliveredTo` is undercounted for successful multi-recipient sends because this only increments the counter once.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| { | ||
| parent::setUp(); | ||
|
|
||
| $appId = \getenv('ONESIGNAL_APP_ID'); |
There was a problem hiding this comment.
P1: Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any ONESIGNAL_* env vars.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/Messaging/Adapter/Push/OneSignalTest.php, line 13:
<comment>Guard this test when OneSignal credentials are missing; otherwise it will fail in CI because the workflow does not provide any `ONESIGNAL_*` env vars.</comment>
<file context>
@@ -0,0 +1,23 @@
+ {
+ parent::setUp();
+
+ $appId = \getenv('ONESIGNAL_APP_ID');
+ $apiKey = \getenv('ONESIGNAL_API_KEY');
+
</file context>
| $response = new Response($this->getType()); | ||
|
|
||
| if ($results['statusCode'] >= 200 && $results['statusCode'] < 300) { | ||
| $response->incrementDeliveredTo(\count($message->getTo())); |
There was a problem hiding this comment.
P2: deliveredTo is undercounted for successful multi-recipient sends because this only increments the counter once.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/Utopia/Messaging/Adapter/Push/OneSignal.php, line 87:
<comment>`deliveredTo` is undercounted for successful multi-recipient sends because this only increments the counter once.</comment>
<file context>
@@ -0,0 +1,99 @@
+ $response = new Response($this->getType());
+
+ if ($results['statusCode'] >= 200 && $results['statusCode'] < 300) {
+ $response->incrementDeliveredTo(\count($message->getTo()));
+ foreach ($message->getTo() as $to) {
+ $response->addResult($to);
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for OneSignal push notification adapter.
Changes:
Summary by cubic
Add a OneSignal push notification adapter to send notifications via OneSignal with device targeting by player IDs. Includes tests and follows the existing push adapter contract.
https://onesignal.com/api/v1/notificationsusingapp_idandAuthorization: Basic.title/body→headings/contents,data,action→url,image→big_picture/ios_attachments,sound→android_sound/ios_sound,badge→ios_badgeType/ios_badgeCount.include_player_ids; supports up to 2000 recipients per request.Response.Written for commit 3fdb82d. Summary will update on new commits.