Conversation
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.
The
subscriber.statusandtransaction.subscriptionStatewere two separate, inconsistently-written sources of truth for a user's subscription status. Android normalized status inside a hidden Mongoosepost('validate')hook on the model; iOS and PayPal each did their own ad-hoc normalization directly in the controller, with PayPal in particular leaving some raw values (likeACTIVE,APPROVAL_PENDING) unnormalized.This PR makes
getSubscriberthe single place that derivessubscriber.status, using a shared normalization helper across all three platforms.api/helpers/subscriptionStatus.js:normalizeSubscriptionStatus()maps raw platform states (including Android'sSUBSCRIPTION_STATE_*constants) into Cboard's internal status vocabulary, falling back tonot_subscribedfor anything unrecognized.PAYPAL_STATUS_MAPmaps PayPal's raw subscription statuses (includingapproval_pending/approved→proccesing, previously left as raw uppercase strings).post('validate')hook fromapi/models/Subscribers.js— the model layer no longer derives business status, only validates shape.api/controllers/subscriber.js: Android, iOS, and PayPal branches ofgetSubscribernow all route through the shared helper. The Android branch normalizes aftersave()resolves and only issues a secondsave()when the computed status actually changes.Test plan
npm test— full suite passes (150 passing; the 1 pre-existing failure inAccess API callsis unrelated to this change)active,expired, andin_grace_periodstatessave()does not trigger a duplicate Google Play API call