Skip to content

Commit

Permalink
Check that the waitlist beta is active when re-redeeming the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Mar 7, 2024
1 parent 9155824 commit 09b5254
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions DuckDuckGo/AppDelegate+Waitlists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Core
import BackgroundTasks
import NetworkProtection
import Waitlist
import BrowserServicesKit

extension AppDelegate {

Expand Down Expand Up @@ -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 {
Expand All @@ -72,7 +78,7 @@ extension AppDelegate {
self?.fetchVPNWaitlistAuthToken(inviteCode: inviteCode)
}
}
#endif

return

}
Expand Down

0 comments on commit 09b5254

Please sign in to comment.