Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display upgrade verification prompt #7454

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,11 @@ Tap the + to start adding people.";
"key_verification_self_verify_current_session_alert_message" = "Other users may not trust it.";
"key_verification_self_verify_current_session_alert_validate_action" = "Verify";

// Legacy to Rust security upgrade

"key_verification_self_verify_security_upgrade_alert_title" = "App updated";
"key_verification_self_verify_security_upgrade_alert_message" = "Secure messaging has been improved with the latest update. Please re-verify your device.";

// Unverified sessions
"key_verification_alert_title" = "You have unverified sessions";
"key_verification_alert_body" = "Review to ensure your account is safe.";
Expand Down
20 changes: 19 additions & 1 deletion Riot/Experiments/CryptoSDKFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ import MatrixSDKCrypto
RiotSettings.shared.enableCryptoSDK
}

var needsVerificationUpgrade: Bool {
get {
return RiotSettings.shared.showVerificationUpgradeAlert
}
set {
RiotSettings.shared.showVerificationUpgradeAlert = newValue
}
}

private static let FeatureName = "ios-crypto-sdk"
private static let FeatureNameV2 = "ios-crypto-sdk-v2"

private let remoteFeature: RemoteFeaturesClientProtocol
private let localFeature: PhasedRolloutFeature

Expand Down Expand Up @@ -98,6 +109,13 @@ import MatrixSDKCrypto
}

private func isFeatureEnabled(userId: String) -> Bool {
remoteFeature.isFeatureEnabled(Self.FeatureName) || localFeature.isEnabled(userId: userId)
// This feature includes app version with a bug, and thus will not be rolled out to 100% users
remoteFeature.isFeatureEnabled(Self.FeatureName)

// Second version of the remote feature with a bugfix and released eventually to 100% users
|| remoteFeature.isFeatureEnabled(Self.FeatureNameV2)

// Local feature
|| localFeature.isEnabled(userId: userId)
}
}
8 changes: 8 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,14 @@ public class VectorL10n: NSObject {
public static var keyVerificationSelfVerifyCurrentSessionAlertValidateAction: String {
return VectorL10n.tr("Vector", "key_verification_self_verify_current_session_alert_validate_action")
}
/// Secure messaging has been improved with the latest update. Please re-verify your device.
public static var keyVerificationSelfVerifySecurityUpgradeAlertMessage: String {
return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_message")
}
/// App updated
public static var keyVerificationSelfVerifySecurityUpgradeAlertTitle: String {
return VectorL10n.tr("Vector", "key_verification_self_verify_security_upgrade_alert_title")
}
/// Review
public static var keyVerificationSelfVerifyUnverifiedSessionsAlertValidateAction: String {
return VectorL10n.tr("Vector", "key_verification_self_verify_unverified_sessions_alert_validate_action")
Expand Down
3 changes: 3 additions & 0 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ final class RiotSettings: NSObject {
@UserDefault(key: "hideVerifyThisSessionAlert", defaultValue: false, storage: defaults)
var hideVerifyThisSessionAlert

@UserDefault(key: "showVerificationUpgradeAlert", defaultValue: false, storage: defaults)
var showVerificationUpgradeAlert

@UserDefault(key: "matrixApps", defaultValue: false, storage: defaults)
var matrixApps

Expand Down
16 changes: 14 additions & 2 deletions Riot/Modules/Home/AllChats/AllChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,20 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
private func presentVerifyCurrentSessionAlert(with session: MXSession) {
MXLog.debug("[AllChatsViewController] presentVerifyCurrentSessionAlertWithSession")

let alert = UIAlertController(title: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertTitle,
message: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertMessage,
let title: String
let message: String

if let feature = MXSDKOptions.sharedInstance().cryptoSDKFeature,
feature.isEnabled && feature.needsVerificationUpgrade {
title = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertTitle
message = VectorL10n.keyVerificationSelfVerifySecurityUpgradeAlertMessage
} else {
title = VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertTitle
message = VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertMessage
}

let alert = UIAlertController(title: title,
message: message,
preferredStyle: .alert)

alert.addAction(UIAlertAction(title: VectorL10n.keyVerificationSelfVerifyCurrentSessionAlertValidateAction,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7454.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Verification: Display upgrade verification prompt