Skip to content
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
3 changes: 1 addition & 2 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Home/AllChats/AllChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Comment thread
pixlwave marked this conversation as resolved.
}
}
25 changes: 25 additions & 0 deletions RiotTests/VerificationRequiredBannerCheckerTests.swift
Original file line number Diff line number Diff line change
@@ -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: "")))
}
}
Loading