Use profile isAPNSProduction as source of truth for Loop APNs environment - #8547
Open
bjorkert wants to merge 3 commits into
Open
Use profile isAPNSProduction as source of truth for Loop APNs environment#8547bjorkert wants to merge 3 commits into
bjorkert wants to merge 3 commits into
Conversation
…ment The APNs environment for Loop remote-command push notifications was determined solely by the LOOP_PUSH_SERVER_ENVIRONMENT environment variable, which has to be configured manually and can drift out of sync with how the Loop app is built. Use the optional top-level isAPNSProduction profile field as the source of truth when present, falling back to LOOP_PUSH_SERVER_ENVIRONMENT otherwise. The explicit undefined check ensures isAPNSProduction: false forces the sandbox environment even when the env var says production.
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.
Summary
When sending Loop remote-command push notifications, the APNs environment (production vs. sandbox) is currently determined solely by the
LOOP_PUSH_SERVER_ENVIRONMENTenvironment variable. This means the environment has to be configured manually on the Nightscout site and can drift out of sync with how the Loop app itself is actually built.Loop is about to start writing an
isAPNSProductionboolean to the uploaded profile (see LoopKit/NightscoutKit#1). This is an optional, top-level profile field that is only serialized when set. This PR makes that field the source of truth when present, and keepsLOOP_PUSH_SERVER_ENVIRONMENTas the fallback.Behavior
isAPNSProduction, it is used directly (true→ production,false→ sandbox).LOOP_PUSH_SERVER_ENVIRONMENT === "production".The
!== undefinedcheck (rather than a truthy fallback) is deliberate so that an explicitisAPNSProduction: falsecorrectly forces the sandbox environment even when the env var saysproduction.Compatibility
Fully backward compatible. Existing deployments where Loop does not yet write the field, or that don't run Loop, behave exactly as before.
Related
isAPNSProductionfield to the uploaded profile.