fix: [SDK-4341] populate push token from raw subscription for local-id models#1455
Closed
sherwinski wants to merge 3 commits intomainfrom
Closed
fix: [SDK-4341] populate push token from raw subscription for local-id models#1455sherwinski wants to merge 3 commits intomainfrom
sherwinski wants to merge 3 commits intomainfrom
Conversation
…d models When login() creates a placeholder SubscriptionModel with a local id and empty token, the subsequent optIn() flow obtains the real push token via rawPushSubscription but Branch 2 of updatePushSubscriptionModelWithRawSubscription discarded it — sending the empty-token model to the server as-is. Extract the model-update logic into updateModelFromRawSubscription() and call it before createSubscribedUser() in the local-id branch so the token, web_auth, and web_p256 fields are populated from the actual push subscription.
…ption Adds a test that reproduces the exact bug conditions: a placeholder model with a local id and token: '' (the state login() creates). Also updates the existing local-id test to expect web_auth and web_p256 fields.
795644c to
6c137d8
Compare
Contributor
|
whats the original issue? is it just this "login() is called before optIn()."? |
Contributor
Author
Yes, specifically It's difficult to reproduce manually which is why I'm basing the fix off of unit tests. |
Contributor
|
Include ticket id in pr title. |
Contributor
|
We need more details from the customer. |
Contributor
Author
|
Closing for now until we hear back |
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.
Description
1 Line Summary
Fix subscriptions created with no push token when
login()is called beforeoptIn().Details
When
login()creates a placeholderSubscriptionModelwith alocal-id and emptytoken: '', the subsequentoptIn()flow obtains the real push token viarawPushSubscription. However, Branch 2 ofupdatePushSubscriptionModelWithRawSubscriptionwas callingcreateSubscribedUser(pushModel)with the stale empty-token model, discarding therawPushSubscriptionentirely:The fix extracts the model-update logic into
updateModelFromRawSubscription()and calls it beforecreateSubscribedUser()in the local-id branch, ensuring the token,web_auth, andweb_p256fields are populated from the actual push subscription data.Systems Affected
Validation
Tests
Info
should populate token from rawPushSubscription when model has local id and empty token (SDK-4341)that reproduces the exact bug conditions: a model with alocal-id andtoken: ''(the realistic state produced bylogin()). This test failed before the fix and now passes.should create user if push subscription model has a local idtest to expect theweb_authandweb_p256fields that are now correctly populated from the raw subscription.Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemapcontextif possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.contextScreenshots
Info
N/A — internal logic fix with no UI changes.
Checklist
Related Tickets