From 09b52548fa1dfb65eeab6052acbd0c9226d35c89 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Thu, 7 Mar 2024 13:30:07 -0800 Subject: [PATCH] Check that the waitlist beta is active when re-redeeming the code. --- DuckDuckGo/AppDelegate+Waitlists.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/AppDelegate+Waitlists.swift b/DuckDuckGo/AppDelegate+Waitlists.swift index db54ce6826..7fae089578 100644 --- a/DuckDuckGo/AppDelegate+Waitlists.swift +++ b/DuckDuckGo/AppDelegate+Waitlists.swift @@ -22,6 +22,7 @@ import Core import BackgroundTasks import NetworkProtection import Waitlist +import BrowserServicesKit extension AppDelegate { @@ -51,12 +52,17 @@ extension AppDelegate { VPNWaitlist.shared.fetchInviteCodeIfAvailable { [weak self] error in guard error == nil else { -#if !DEBUG + if error == .alreadyHasInviteCode, UIApplication.shared.applicationState == .active { // If the user already has an invite code but their auth token has gone missing, attempt to redeem it again. let tokenStore = NetworkProtectionKeychainTokenStore() let waitlistStorage = VPNWaitlist.shared.waitlistStorage - if let inviteCode = waitlistStorage.getWaitlistInviteCode(), !tokenStore.isFeatureActivated { + let configManager = ContentBlocking.shared.privacyConfigurationManager + let waitlistBetaActive = configManager.privacyConfig.isSubfeatureEnabled(NetworkProtectionSubfeature.waitlistBetaActive) + + if let inviteCode = waitlistStorage.getWaitlistInviteCode(), + !tokenStore.isFeatureActivated, + waitlistBetaActive { let pixel: Pixel.Event = .networkProtectionWaitlistRetriedInviteCodeRedemption do { @@ -72,7 +78,7 @@ extension AppDelegate { self?.fetchVPNWaitlistAuthToken(inviteCode: inviteCode) } } -#endif + return }