diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 3851deb853..b27765ad5c 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -3376,8 +3376,7 @@ - (void)checkCrossSigningForSession:(MXSession*)mxSession case MXCrossSigningStateCrossSigningExists: MXLogDebug(@"[AppDelegate] handleAppState: presentVerifyCurrentSessionAlertIfNeededWithSession"); [self.masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:mxSession]; - // Temporarily disabled until we have a way to reset from the verification screen. - // [self.masterTabBarController presentVerificationRequiredBannerWithSession:mxSession]; + [self.masterTabBarController presentVerificationRequiredBannerWithSession:mxSession]; break; case MXCrossSigningStateCanCrossSign: MXLogDebug(@"[AppDelegate] handleAppState: presentReviewUnverifiedSessionsAlertIfNeededWithSession"); diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index f47e9622bb..ca50a99404 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -849,7 +849,7 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol { } func presentVerificationRequiredBanner(with session: MXSession) { - guard bannerView == nil else { + guard bannerView == nil, VerificationRequiredBannerChecker().canShowBanner(for: session) else { return } diff --git a/Riot/Modules/Home/VerificationRequiredBanner/VerificationRequiredBannerChecker.swift b/Riot/Modules/Home/VerificationRequiredBanner/VerificationRequiredBannerChecker.swift new file mode 100644 index 0000000000..7670558302 --- /dev/null +++ b/Riot/Modules/Home/VerificationRequiredBanner/VerificationRequiredBannerChecker.swift @@ -0,0 +1,22 @@ +// +// Copyright 2022-2024 New Vector Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import Foundation +import CryptoKit + +struct VerificationRequiredBannerChecker { + func canShowBanner(for session: MXSession) -> Bool { + guard let userID = session.myUserId, + let serverName = MXTools.serverName(inMatrixIdentifier: userID), + let data = serverName.components(separatedBy: ".").suffix(2).joined(separator: ".").data(using: .utf8) else { + return true + } + + let hash = SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined() + return hash != "9e6d1ca3e739dd3f879b8046af783402a34d247f879dfa1b531edbd56a56c1a6" + } +} diff --git a/RiotTests/VerificationRequiredBannerCheckerTests.swift b/RiotTests/VerificationRequiredBannerCheckerTests.swift new file mode 100644 index 0000000000..ad70f19df8 --- /dev/null +++ b/RiotTests/VerificationRequiredBannerCheckerTests.swift @@ -0,0 +1,25 @@ +// +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. +// + +import XCTest + +@testable import Element + +class VerificationRequiredBannerCheckerTests: XCTestCase { + private let checker = VerificationRequiredBannerChecker() + + func testCanShowBanner() { + XCTAssertTrue(checker.canShowBanner(for: makeSession(userID: "@user:example.com"))) + XCTAssertTrue(checker.canShowBanner(for: makeSession(userID: "@user:matrix.org"))) + } + + private func makeSession(userID: String) -> MXSession! { + MXSession(matrixRestClient: .init(credentials: .init(homeServer: "", + userId: userID, + accessToken: ""))) + } +}