diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Database/DataBrokerProtectionDatabase.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Database/DataBrokerProtectionDatabase.swift index cf46f74afc..3588edbfe8 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Database/DataBrokerProtectionDatabase.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Database/DataBrokerProtectionDatabase.swift @@ -64,6 +64,7 @@ public protocol DataBrokerProtectionRepository { func fetchOptOutHistoryEvents(brokerId: Int64, profileQueryId: Int64, extractedProfileId: Int64) throws -> [HistoryEvent] func hasMatches() throws -> Bool + func fetchAllAttempts() throws -> [AttemptInformation] func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? func addAttempt(extractedProfileId: Int64, attemptUUID: UUID, dataBroker: String, lastStageDate: Date, startTime: Date) throws } @@ -487,6 +488,17 @@ final class DataBrokerProtectionDatabase: DataBrokerProtectionRepository { } } + func fetchAllAttempts() throws -> [AttemptInformation] { + do { + let vault = try self.vault ?? DataBrokerProtectionSecureVaultFactory.makeVault(reporter: secureVaultErrorReporter) + return try vault.fetchAllAttempts() + } catch { + Logger.dataBrokerProtection.error("Database error: fetchAllAttempts, error: \(error.localizedDescription, privacy: .public)") + pixelHandler.fire(.generalError(error: error, functionOccurredIn: "DataBrokerProtectionDatabase.fetchAllAttempts")) + throw error + } + } + func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? { do { let vault = try self.vault ?? DataBrokerProtectionSecureVaultFactory.makeVault(reporter: secureVaultErrorReporter) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBaseBrowser/DataBrokerDatabaseBrowserViewModel.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBaseBrowser/DataBrokerDatabaseBrowserViewModel.swift index 36eaf1b8ac..fe002d8d12 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBaseBrowser/DataBrokerDatabaseBrowserViewModel.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBaseBrowser/DataBrokerDatabaseBrowserViewModel.swift @@ -48,7 +48,8 @@ final class DataBrokerDatabaseBrowserViewModel: ObservableObject { guard let dataManager = self.dataManager else { return } Task { - guard let data = try? dataManager.fetchBrokerProfileQueryData(ignoresCache: true) else { + guard let data = try? dataManager.fetchBrokerProfileQueryData(ignoresCache: true), + let attempts = try? dataManager.fetchAllOptOutAttempts() else { assertionFailure("DataManager error during DataBrokerDatavaseBrowserViewModel.updateTables") return } @@ -68,9 +69,10 @@ final class DataBrokerDatabaseBrowserViewModel: ObservableObject { let optOutsTable = createTable(using: optOutJobs, tableName: "OptOutOperation") let extractedProfilesTable = createTable(using: extractedProfiles, tableName: "ExtractedProfile") let eventsTable = createTable(using: events.sorted(by: { $0.date < $1.date }), tableName: "Events") + let attemptsTable = createTable(using: attempts.sorted(by: <), tableName: "OptOutAttempts") DispatchQueue.main.async { - self.tables = [brokersTable, profileQueriesTable, scansTable, optOutsTable, extractedProfilesTable, eventsTable] + self.tables = [brokersTable, profileQueriesTable, scansTable, optOutsTable, extractedProfilesTable, eventsTable, attemptsTable] } } } @@ -136,3 +138,25 @@ struct DataBrokerDatabaseBrowserData { } } + +extension DataBrokerProtectionDataManager { + func fetchAllOptOutAttempts() throws -> [AttemptInformation] { + try database.fetchAllAttempts() + } +} + +extension AttemptInformation: Comparable { + public static func < (lhs: AttemptInformation, rhs: AttemptInformation) -> Bool { + if lhs.extractedProfileId != rhs.extractedProfileId { + return lhs.extractedProfileId < rhs.extractedProfileId + } else if lhs.dataBroker != rhs.dataBroker { + return lhs.dataBroker < rhs.dataBroker + } else { + return lhs.startDate < rhs.startDate + } + } + + public static func == (lhs: AttemptInformation, rhs: AttemptInformation) -> Bool { + lhs.attemptId == rhs.attemptId + } +} diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Operations/DataBrokerProfileQueryOperationManager.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Operations/DataBrokerProfileQueryOperationManager.swift index 56d91bf7e0..6bb37ceb99 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Operations/DataBrokerProfileQueryOperationManager.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Operations/DataBrokerProfileQueryOperationManager.swift @@ -353,10 +353,10 @@ struct DataBrokerProfileQueryOperationManager: OperationsManager { profileQueryId: profileQueryId) try database.addAttempt(extractedProfileId: extractedProfileId, - attemptUUID: stageDurationCalculator.attemptId, - dataBroker: stageDurationCalculator.dataBroker, - lastStageDate: stageDurationCalculator.lastStateTime, - startTime: stageDurationCalculator.startTime) + attemptUUID: stageDurationCalculator.attemptId, + dataBroker: stageDurationCalculator.dataBroker, + lastStageDate: stageDurationCalculator.lastStateTime, + startTime: stageDurationCalculator.startTime) try database.add(.init(extractedProfileId: extractedProfileId, brokerId: brokerId, profileQueryId: profileQueryId, type: .optOutRequested)) try incrementAttemptCountIfNeeded( database: database, diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/advancedbackgroundchecks.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/advancedbackgroundchecks.com.json index 16b181016c..f67fc54a9e 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/advancedbackgroundchecks.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/advancedbackgroundchecks.com.json @@ -64,7 +64,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/backgroundcheck.run.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/backgroundcheck.run.json index e8bbbc15a8..19089bf1c8 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/backgroundcheck.run.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/backgroundcheck.run.json @@ -58,7 +58,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/centeda.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/centeda.com.json index 3002debea8..649c73d8e4 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/centeda.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/centeda.com.json @@ -66,7 +66,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clubset.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clubset.com.json index d987522452..08ba29ac2f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clubset.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clubset.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clustrmaps.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clustrmaps.com.json index ac577cabc6..2566b8404c 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clustrmaps.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/clustrmaps.com.json @@ -58,7 +58,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/councilon.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/councilon.com.json index 1949f6288d..5d7a4676c2 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/councilon.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/councilon.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/curadvisor.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/curadvisor.com.json index e11686b43e..52f21e4ec4 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/curadvisor.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/curadvisor.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/cyberbackgroundchecks.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/cyberbackgroundchecks.com.json index 30736cb297..a942818666 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/cyberbackgroundchecks.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/cyberbackgroundchecks.com.json @@ -60,7 +60,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/dataveria.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/dataveria.com.json index 9e31159eda..9c26fd83b7 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/dataveria.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/dataveria.com.json @@ -67,7 +67,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fakebroker.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fakebroker.com.json index df5bc08a9c..15f80d0e88 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fakebroker.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fakebroker.com.json @@ -89,7 +89,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 0, - "maintenanceScan": 240 + "maintenanceScan": 120 }, "addedDatetime": 1725632531153, "version": "0.0.1" diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastbackgroundcheck.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastbackgroundcheck.com.json index b5d250e53f..3e687a1cde 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastbackgroundcheck.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastbackgroundcheck.com.json @@ -68,7 +68,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastpeoplesearch.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastpeoplesearch.com.json index 34ecb0065e..b218bccaae 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastpeoplesearch.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/fastpeoplesearch.com.json @@ -61,7 +61,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/freepeopledirectory.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/freepeopledirectory.com.json index 8ed0aac9c3..b5e422c85f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/freepeopledirectory.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/freepeopledirectory.com.json @@ -56,7 +56,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/inforver.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/inforver.com.json index 76f790389d..c348e6dc87 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/inforver.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/inforver.com.json @@ -64,7 +64,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/kwold.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/kwold.com.json index a25eae700b..93f84b98bd 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/kwold.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/kwold.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/mylife.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/mylife.com.json index b20b1ce7b1..563533249c 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/mylife.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/mylife.com.json @@ -137,7 +137,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/neighbor.report.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/neighbor.report.json index df59931d69..ddb33cc776 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/neighbor.report.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/neighbor.report.json @@ -224,7 +224,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/newenglandfacts.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/newenglandfacts.com.json index 80ad0f98e6..64e89ec933 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/newenglandfacts.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/newenglandfacts.com.json @@ -68,7 +68,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/officialusa.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/officialusa.com.json index 0311e6ab8f..19ce820d0f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/officialusa.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/officialusa.com.json @@ -49,7 +49,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-background-check.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-background-check.com.json index f835fa7e9b..ef1ec3b8b6 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-background-check.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-background-check.com.json @@ -58,7 +58,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-wizard.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-wizard.com.json index 50822cda4b..94fe5de382 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-wizard.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/people-wizard.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplefinders.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplefinders.com.json index c0fb60590d..af0df1dd5c 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplefinders.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplefinders.com.json @@ -237,7 +237,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplesearchnow.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplesearchnow.com.json index 981412fb88..f5173b38d0 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplesearchnow.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplesearchnow.com.json @@ -60,7 +60,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswhizr.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswhizr.com.json index 71be18694b..7bb8308173 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswhizr.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswhizr.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswiz.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswiz.com.json index a747fda227..31f263870d 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswiz.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswiz.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswizard.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswizard.com.json index a52aae377c..7133fdbcf5 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswizard.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peopleswizard.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.com.json index f96c8e8442..8b475689b4 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.com.json @@ -172,7 +172,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.net.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.net.json index 7d047f55b2..8eeb4960b3 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.net.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhiz.net.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.com.json index 5468e4da6a..0b7c89755b 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.net.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.net.json index d018a7904a..08cee8b072 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.net.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhized.net.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.com.json index e71400b7af..a6ca8f747f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.net.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.net.json index 38808c002d..8a3e058db5 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.net.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewhizr.net.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewiz.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewiz.com.json index fafa2b147a..bb447214b8 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewiz.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewiz.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizard.net.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizard.net.json index aa1a490043..96c7e98ec9 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizard.net.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizard.net.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizr.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizr.com.json index 2efd07019e..33286fb153 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizr.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/peoplewizr.com.json @@ -51,7 +51,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/pub360.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/pub360.com.json index 9ff5f18343..3468d99abd 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/pub360.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/pub360.com.json @@ -66,7 +66,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/publicreports.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/publicreports.com.json index 3d4ba55c99..765db7cfca 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/publicreports.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/publicreports.com.json @@ -69,7 +69,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/quickpeopletrace.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/quickpeopletrace.com.json index 40c0f32450..f92ed39e0e 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/quickpeopletrace.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/quickpeopletrace.com.json @@ -52,7 +52,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/searchpeoplefree.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/searchpeoplefree.com.json index 9030bb9881..33349306e6 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/searchpeoplefree.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/searchpeoplefree.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/smartbackgroundchecks.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/smartbackgroundchecks.com.json index 1a9b2f0731..dd0f949829 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/smartbackgroundchecks.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/smartbackgroundchecks.com.json @@ -61,7 +61,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/spokeo.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/spokeo.com.json index 816edab308..eb9282d064 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/spokeo.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/spokeo.com.json @@ -172,7 +172,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/truepeoplesearch.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/truepeoplesearch.com.json index 3399ba4eba..1ae7bf3e1f 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/truepeoplesearch.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/truepeoplesearch.com.json @@ -62,7 +62,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usa-people-search.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usa-people-search.com.json index c9d0e7b9cb..a42f3d621a 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usa-people-search.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usa-people-search.com.json @@ -65,7 +65,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usatrace.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usatrace.com.json index f7f18b0ed6..13d6543024 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usatrace.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usatrace.com.json @@ -52,7 +52,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usphonebook.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usphonebook.com.json index d57ed99fcc..829f039d3e 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usphonebook.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/usphonebook.com.json @@ -59,7 +59,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/verecor.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/verecor.com.json index 8fefb22828..a18762965a 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/verecor.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/verecor.com.json @@ -138,7 +138,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/vericora.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/vericora.com.json index 74791e696e..eed297543e 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/vericora.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/vericora.com.json @@ -67,7 +67,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veriforia.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veriforia.com.json index ffd225fa43..94cbdec2cc 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veriforia.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veriforia.com.json @@ -67,7 +67,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veripages.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veripages.com.json index 77994fe0f9..3088681e36 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veripages.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/veripages.com.json @@ -69,7 +69,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/virtory.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/virtory.com.json index 05f656e3c7..2291c1ec45 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/virtory.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/virtory.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/wellnut.com.json b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/wellnut.com.json index af093149a4..a65f88f281 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/wellnut.com.json +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Resources/JSON/wellnut.com.json @@ -70,7 +70,7 @@ "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionDatabaseProvider.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionDatabaseProvider.swift index 15f9e7a858..2dfc55983e 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionDatabaseProvider.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionDatabaseProvider.swift @@ -100,6 +100,7 @@ protocol DataBrokerProtectionDatabaseProvider: SecureStorageDatabaseProvider { func hasMatches() throws -> Bool + func fetchAllAttempts() throws -> [OptOutAttemptDB] func fetchAttemptInformation(for extractedProfileId: Int64) throws -> OptOutAttemptDB? func save(_ optOutAttemptDB: OptOutAttemptDB) throws } @@ -619,6 +620,12 @@ final class DefaultDataBrokerProtectionDatabaseProvider: GRDBSecureStorageDataba } } + func fetchAllAttempts() throws -> [OptOutAttemptDB] { + try db.read { db in + return try OptOutAttemptDB.fetchAll(db) + } + } + func fetchAttemptInformation(for extractedProfileId: Int64) throws -> OptOutAttemptDB? { try db.read { db in return try OptOutAttemptDB.fetchOne(db, key: extractedProfileId) @@ -627,7 +634,14 @@ final class DefaultDataBrokerProtectionDatabaseProvider: GRDBSecureStorageDataba func save(_ optOutAttemptDB: OptOutAttemptDB) throws { try db.write { db in - try optOutAttemptDB.insert(db) + // We originally intended for ExtractedProfileDB to have a one-to-many relationship with OptOutAttemptDB, + // but it somehow ended up as a one-to-one relationship instead. + // + // This serves as a temporary workaround to keep the opt-out retry mechanism functioning. + // We'll need to address this issue properly in the future. + // + // https://app.asana.com/0/1205591970852438/1208761697124514/f + try optOutAttemptDB.upsert(db) } } } diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionSecureVault.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionSecureVault.swift index 4fd78c5c32..3cf0b4d9bb 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionSecureVault.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Storage/DataBrokerProtectionSecureVault.swift @@ -107,6 +107,7 @@ protocol DataBrokerProtectionSecureVault: SecureVault { func hasMatches() throws -> Bool + func fetchAllAttempts() throws -> [AttemptInformation] func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? func save(extractedProfileId: Int64, attemptUUID: UUID, dataBroker: String, lastStageDate: Date, startTime: Date) throws } @@ -445,6 +446,11 @@ final class DefaultDataBrokerProtectionSecureVault [AttemptInformation] { + let mapper = MapperToModel(mechanism: l2Decrypt(data:)) + return try self.providers.database.fetchAllAttempts().map(mapper.mapToModel(_:)) + } + func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? { let mapper = MapperToModel(mechanism: l2Decrypt(data:)) if let attemptDB = try self.providers.database.fetchAttemptInformation(for: extractedProfileId) { diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/BrokerJSONCodableTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/BrokerJSONCodableTests.swift index cd31d9a94b..bc1cb9e0ed 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/BrokerJSONCodableTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/BrokerJSONCodableTests.swift @@ -168,7 +168,7 @@ final class BrokerJSONCodableTests: XCTestCase { "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } @@ -317,7 +317,7 @@ final class BrokerJSONCodableTests: XCTestCase { "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } @@ -423,7 +423,7 @@ final class BrokerJSONCodableTests: XCTestCase { "schedulingConfig": { "retryError": 48, "confirmOptOutScan": 72, - "maintenanceScan": 240, + "maintenanceScan": 120, "maxAttempts": -1 } } diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProfileQueryOperationManagerTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProfileQueryOperationManagerTests.swift index c41dd0bb3c..5e772ac0ee 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProfileQueryOperationManagerTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProfileQueryOperationManagerTests.swift @@ -371,15 +371,22 @@ final class DataBrokerProfileQueryOperationManagerTests: XCTestCase { func testWhenRemovedProfileIsFound_thenOptOutConfirmedIsAddedRemoveDateIsUpdatedAndPreferredRunDateIsSetToNil() async { do { + let extractedProfileId: Int64 = 1 + let brokerId: Int64 = 1 + let profileQueryId: Int64 = 1 + let mockHistoryEvent = HistoryEvent(extractedProfileId: extractedProfileId, brokerId: brokerId, profileQueryId: profileQueryId, type: .optOutRequested) + let mockBrokerProfileQuery = BrokerProfileQueryData( + dataBroker: .mock, + profileQuery: .mock, + scanJobData: .mock, + optOutJobData: [.mock(with: .mockWithoutRemovedDate, preferredRunDate: Date(), historyEvents: [mockHistoryEvent])] + ) + mockWebOperationRunner.scanResults = [.mockWithoutId] + mockDatabase.brokerProfileQueryDataToReturn = [mockBrokerProfileQuery] _ = try await sut.runScanOperation( on: mockWebOperationRunner, - brokerProfileQueryData: .init( - dataBroker: .mock, - profileQuery: .mock, - scanJobData: .mock, - optOutJobData: [OptOutJobData.mock(with: .mockWithoutRemovedDate)] - ), + brokerProfileQueryData: mockBrokerProfileQuery, database: mockDatabase, notificationCenter: .default, pixelHandler: MockDataBrokerProtectionPixelsHandler(), @@ -389,6 +396,8 @@ final class DataBrokerProfileQueryOperationManagerTests: XCTestCase { XCTAssertTrue(mockDatabase.optOutEvents.contains(where: { $0.type == .optOutConfirmed })) XCTAssertTrue(mockDatabase.wasUpdateRemoveDateCalled) XCTAssertNotNil(mockDatabase.extractedProfileRemovedDate) + XCTAssertTrue(mockDatabase.wasUpdatedPreferredRunDateForOptOutCalled) + XCTAssertNil(mockDatabase.lastPreferredRunDateOnOptOut) } catch { XCTFail("Should not throw") } diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift index 827f21fd18..a5af6fde33 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift @@ -769,6 +769,10 @@ final class DataBrokerProtectionSecureVaultMock: DataBrokerProtectionSecureVault return 1 } + func fetchAllAttempts() throws -> [AttemptInformation] { + [] + } + func fetchAttemptInformation(for extractedProfileId: Int64) throws -> AttemptInformation? { return nil } @@ -990,6 +994,10 @@ final class MockDatabase: DataBrokerProtectionRepository { return extractedProfilesFromBroker } + func fetchAllAttempts() throws -> [AttemptInformation] { + [attemptInformation].compactMap { $0 } + } + func fetchAttemptInformation(for extractedProfileId: Int64) -> AttemptInformation? { return attemptInformation } @@ -1203,8 +1211,9 @@ extension ScanJobData { extension OptOutJobData { static func mock(with extractedProfile: ExtractedProfile, + preferredRunDate: Date? = nil, historyEvents: [HistoryEvent] = [HistoryEvent]()) -> OptOutJobData { - .init(brokerId: 1, profileQueryId: 1, createdDate: Date(), historyEvents: historyEvents, attemptCount: 0, extractedProfile: extractedProfile) + .init(brokerId: 1, profileQueryId: 1, createdDate: Date(), preferredRunDate: preferredRunDate, historyEvents: historyEvents, attemptCount: 0, extractedProfile: extractedProfile) } static func mock(with createdDate: Date) -> OptOutJobData {