Enforce that Backup Subscriptions are only redeemed in the main app
This commit is contained in:
parent
aeadb98cb4
commit
951a481d45
@ -397,6 +397,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
)
|
||||
let globalsContinuation = await schemaMigrationContinuation.migrateDatabaseSchema()
|
||||
let dataMigrationContinuation = globalsContinuation.initGlobals(
|
||||
appContext: launchContext.appContext,
|
||||
appReadiness: appReadiness,
|
||||
backupArchiveErrorPresenterFactory: BackupArchiveErrorPresenterFactoryInternal(),
|
||||
deviceBatteryLevelManager: DeviceBatteryLevelManagerImpl(),
|
||||
|
||||
@ -56,11 +56,12 @@ class NSEEnvironment {
|
||||
|
||||
let finalContinuation = await AppSetup()
|
||||
.start(
|
||||
appContext: CurrentAppContext(),
|
||||
appContext: appContext,
|
||||
databaseStorage: databaseStorage,
|
||||
)
|
||||
.migrateDatabaseSchema()
|
||||
.initGlobals(
|
||||
appContext: appContext,
|
||||
appReadiness: appReadiness,
|
||||
backupArchiveErrorPresenterFactory: NoOpBackupArchiveErrorPresenterFactory(),
|
||||
deviceBatteryLevelManager: nil,
|
||||
|
||||
@ -170,6 +170,7 @@ extension AppSetup {
|
||||
extension AppSetup.GlobalsContinuation {
|
||||
@MainActor
|
||||
public func initGlobals(
|
||||
appContext: AppContext,
|
||||
appReadiness: AppReadiness,
|
||||
backupArchiveErrorPresenterFactory: BackupArchiveErrorPresenterFactory,
|
||||
deviceBatteryLevelManager: (any DeviceBatteryLevelManager)?,
|
||||
@ -478,6 +479,7 @@ extension AppSetup.GlobalsContinuation {
|
||||
|
||||
let backupSubscriptionIssueStore = BackupSubscriptionIssueStore()
|
||||
let backupSubscriptionManager = BackupSubscriptionManagerImpl(
|
||||
appContext: appContext,
|
||||
backupPlanManager: backupPlanManager,
|
||||
backupSubscriptionIssueStore: backupSubscriptionIssueStore,
|
||||
backupSubscriptionRedeemer: BackupSubscriptionRedeemer(
|
||||
|
||||
@ -151,6 +151,7 @@ final class BackupSubscriptionManagerImpl: BackupSubscriptionManager {
|
||||
|
||||
private let logger = PrefixedLogger(prefix: "[Backups][Sub]")
|
||||
|
||||
private let appContext: AppContext
|
||||
private let backupPlanManager: BackupPlanManager
|
||||
private let backupSubscriptionIssueStore: BackupSubscriptionIssueStore
|
||||
private let backupSubscriptionRedeemer: BackupSubscriptionRedeemer
|
||||
@ -163,6 +164,7 @@ final class BackupSubscriptionManagerImpl: BackupSubscriptionManager {
|
||||
private let whoAmIManager: WhoAmIManager
|
||||
|
||||
init(
|
||||
appContext: AppContext,
|
||||
backupPlanManager: BackupPlanManager,
|
||||
backupSubscriptionIssueStore: BackupSubscriptionIssueStore,
|
||||
backupSubscriptionRedeemer: BackupSubscriptionRedeemer,
|
||||
@ -173,6 +175,7 @@ final class BackupSubscriptionManagerImpl: BackupSubscriptionManager {
|
||||
tsAccountManager: TSAccountManager,
|
||||
whoAmIManager: WhoAmIManager,
|
||||
) {
|
||||
self.appContext = appContext
|
||||
self.backupPlanManager = backupPlanManager
|
||||
self.backupSubscriptionIssueStore = backupSubscriptionIssueStore
|
||||
self.backupSubscriptionRedeemer = backupSubscriptionRedeemer
|
||||
@ -573,6 +576,10 @@ final class BackupSubscriptionManagerImpl: BackupSubscriptionManager {
|
||||
}
|
||||
|
||||
private func _redeemSubscriptionIfNecessary() async throws {
|
||||
guard appContext.isMainApp else {
|
||||
throw OWSAssertionError("Shouldn't be redeeming subscripions outside the main app process!")
|
||||
}
|
||||
|
||||
if
|
||||
let preexistingRedemptionContext = db.read(block: {
|
||||
return BackupSubscriptionRedemptionContext.fetch(tx: $0)
|
||||
|
||||
@ -71,6 +71,7 @@ public class MockSSKEnvironment {
|
||||
keychainStorage: keychainStorage,
|
||||
),
|
||||
).migrateDatabaseSchema().initGlobals(
|
||||
appContext: testAppContext,
|
||||
appReadiness: appReadiness,
|
||||
backupArchiveErrorPresenterFactory: NoOpBackupArchiveErrorPresenterFactory(),
|
||||
deviceBatteryLevelManager: nil,
|
||||
|
||||
@ -89,6 +89,7 @@ public class ShareViewController: OWSNavigationController, ShareViewDelegate, SA
|
||||
)
|
||||
.migrateDatabaseSchema()
|
||||
.initGlobals(
|
||||
appContext: appContext,
|
||||
appReadiness: appReadiness,
|
||||
backupArchiveErrorPresenterFactory: NoOpBackupArchiveErrorPresenterFactory(),
|
||||
deviceBatteryLevelManager: nil,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user