From 8255ffda2014611bb562a422a4ebeab82ddaa757 Mon Sep 17 00:00:00 2001 From: Michal Smaga Date: Mon, 1 Jul 2024 00:10:36 +0200 Subject: [PATCH] Remove Privacy Pro from device once expired account is deleted (#2922) Task/Issue URL: https://app.asana.com/0/1200019156869587/1207492658883345/f **Description**: When fetching subscription info a 401 response means that the token is no longer valid. As a result we should sign out the user. --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- DuckDuckGo/Application/AppDelegate.swift | 12 ++++++------ LocalPackages/DataBrokerProtection/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/SubscriptionUI/Package.swift | 2 +- UnitTests/DBP/Mocks/DataBrokerProtectionMocks.swift | 3 --- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 967ad9c709..6e4abacfe7 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -13042,7 +13042,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 163.0.1; + version = 164.0.0; }; }; 9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6653e100c6..66904431e9 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "39e10c8eeddeb03750350597bd55fd8c43b5fd83", - "version" : "163.0.1" + "revision" : "be669f88c20b862b43e6267004c45022447209ee", + "version" : "164.0.0" } }, { diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index cb60be233a..17c86dd828 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -377,12 +377,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate { syncService?.initializeIfNeeded() syncService?.scheduler.notifyAppLifecycleEvent() - subscriptionManager.updateSubscriptionStatus { isActive in - if isActive { - PixelKit.fire(PrivacyProPixel.privacyProSubscriptionActive, frequency: .daily) - } - } - NetworkProtectionAppEvents(featureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager)).applicationDidBecomeActive() #if DBP @@ -393,6 +387,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate { AppPrivacyFeatures.shared.contentBlocking.privacyConfigurationManager.toggleProtectionsCounter.sendEventsIfNeeded() + subscriptionManager.refreshCachedSubscriptionAndEntitlements { isSubscriptionActive in + if isSubscriptionActive { + PixelKit.fire(PrivacyProPixel.privacyProSubscriptionActive, frequency: .daily) + } + } + Task { @MainActor in await vpnRedditSessionWorkaround.installRedditSessionWorkaround() } diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index 3324dc1ed4..97abf62148 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "163.0.1"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "164.0.0"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper"), ], diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index ca000becd8..88469792bc 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -32,7 +32,7 @@ let package = Package( .library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "163.0.1"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "164.0.0"), .package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.1"), .package(path: "../AppLauncher"), .package(path: "../UDSHelper"), diff --git a/LocalPackages/SubscriptionUI/Package.swift b/LocalPackages/SubscriptionUI/Package.swift index d01793e926..af82e98f6b 100644 --- a/LocalPackages/SubscriptionUI/Package.swift +++ b/LocalPackages/SubscriptionUI/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["SubscriptionUI"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "163.0.1"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "164.0.0"), .package(path: "../SwiftUIExtensions") ], targets: [ diff --git a/UnitTests/DBP/Mocks/DataBrokerProtectionMocks.swift b/UnitTests/DBP/Mocks/DataBrokerProtectionMocks.swift index dfe3442e8a..bbcd473a1f 100644 --- a/UnitTests/DBP/Mocks/DataBrokerProtectionMocks.swift +++ b/UnitTests/DBP/Mocks/DataBrokerProtectionMocks.swift @@ -73,9 +73,6 @@ final class MockAccountManager: AccountManager { .success(AccountDetails(email: "", externalID: "")) } - func refreshSubscriptionAndEntitlements() async { - } - func checkForEntitlements(wait waitTime: Double, retry retryCount: Int) async -> Bool { true }