Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Fix/14480: Wrong text in SRS dialog "Andere warnen nicht möglich" for error MIN_TIME_SINCE_ONBOARDING #4973

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ Bei ausgeschalteter Hintergrundaktualisierung müssen Sie die App täglich aufru

"ExposureSubmissionDispatch_SRSWarnOthersPreconditionError_title" = "Andere warnen nicht möglich";

"ExposureSubmissionDispatch_SRSWarnOthersPreconditionError_insufficientAppUsageTime_message" = "Leider können Sie momentan andere noch nicht warnen, da Sie die App noch nicht lange genug installiert haben. Dies dient der Vermeidung von Missbrauch.\nEinen offiziellen Test können Sie jederzeit registrieren und andere damit warnen. (Fehlercode %@)";
"ExposureSubmissionDispatch_SRSWarnOthersPreconditionError_insufficientAppUsageTime_message" = "Aus Sicherheitsgründen können Sie erst %@ Stunden, nachdem Sie die App installiert oder aktualisiert haben, diese Art von Warnung senden. Bitte versuchen Sie es in %@ Stunden erneut. (Fehlercode %@)";

"ExposureSubmissionDispatch_SRSWarnOthersPreconditionError_positiveTestResultWasAlreadySubmittedWithinThresholdDays_message" = "Sie können momentan andere nicht warnen, da Sie innerhalb der vergangenen %@ Tage bereits ein positives Testergebnis gemeldet haben. Dies dient der Vermeidung von Missbrauch.\nEinen offiziellen Test können Sie jederzeit registrieren und andere damit warnen. (Fehlercode %@)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ final class SRSPreconditionErrorTests: CWATestCase {

func testInsufficientAppUsageTime_Message() {
// GIVEN
let sut = SRSPreconditionError.insufficientAppUsageTime
let timeSinceOnboardingInHours = 42
let timeStillToWaitInHours = 23
let sut = SRSPreconditionError.insufficientAppUsageTime(
timeSinceOnboardingInHours: timeSinceOnboardingInHours,
timeStillToWaitInHours: timeStillToWaitInHours
)

// THEN
XCTAssertEqual(
sut.message,
String(
format: AppStrings.ExposureSubmissionDispatch.SRSWarnOthersPreconditionAlert.insufficientAppUsageTimeMessage,
String(timeSinceOnboardingInHours),
String(timeStillToWaitInHours),
sut.errorCode
)
)
Expand All @@ -55,7 +62,7 @@ final class SRSPreconditionErrorTests: CWATestCase {

func testErrorCode_EqualTo_ErrorDescription() {
// GIVEN
let sut = SRSPreconditionError.insufficientAppUsageTime
let sut = SRSPreconditionError.insufficientAppUsageTime(timeSinceOnboardingInHours: 42, timeStillToWaitInHours: 42)

// THEN
XCTAssertEqual(sut.errorCode, sut.description)
Expand All @@ -75,7 +82,7 @@ final class SRSPreconditionErrorTests: CWATestCase {
XCTAssertEqual(sut.description, "DEVICE_TIME_UNVERIFIED")

// WHEN
sut = .insufficientAppUsageTime
sut = SRSPreconditionError.insufficientAppUsageTime(timeSinceOnboardingInHours: 42, timeStillToWaitInHours: 42)

// THEN
XCTAssertEqual(sut.description, "MIN_TIME_SINCE_ONBOARDING")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum SRSPreconditionError: Error {
case deviceTimeError(PPACError)

/// Precondition: the app was installed less than 48h
case insufficientAppUsageTime
case insufficientAppUsageTime(timeSinceOnboardingInHours: Int, timeStillToWaitInHours: Int)

/// Precondition: there was already a key submission without a registered test, depending from configuration (for e.g. in the last 3 months)
case positiveTestResultWasAlreadySubmittedWithinThreshold(timeBetweenSubmissionsInDays: Int)
Expand All @@ -22,9 +22,11 @@ enum SRSPreconditionError: Error {
format: AppStrings.ExposureSubmissionDispatch.SRSWarnOthersPreconditionAlert.deviceCheckError,
errorCode
)
case .insufficientAppUsageTime:
case .insufficientAppUsageTime(let timeSinceOnboardingInHours, let timeStillToWaitInHours):
return String(
format: AppStrings.ExposureSubmissionDispatch.SRSWarnOthersPreconditionAlert.insufficientAppUsageTimeMessage,
String(timeSinceOnboardingInHours),
String(timeStillToWaitInHours),
errorCode
)
case .positiveTestResultWasAlreadySubmittedWithinThreshold(let timeBetweenSubmissionsInDays):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ class PPACService: PrivacyPreservingAccessControl {

if difference < minTimeSinceOnboarding {
Log.error("SRSError: too short time since onboarding", log: .ppac)
completion(.failure(.insufficientAppUsageTime))

// Default is 1 to avoid texts like "wait for 0 hours" ...
let timeStillToWaitInHours = difference == 0 ? 1 : difference

completion(
.failure(
.insufficientAppUsageTime(
timeSinceOnboardingInHours: minTimeSinceOnboarding,
timeStillToWaitInHours: timeStillToWaitInHours
)
)
)
return
}
}
Expand Down