mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Show Encryption Authenticity warnings on messages in the timeline. (#3051)
* Initial implementation. * Add developer option for showing timeline item authenticity. * Refactor code to use new SendInfo.Status. --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright 2024 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
/// Represents and issue with a timeline item's authenticity such as coming from an
|
||||
/// unsigned session or being sent unencrypted in an encrypted room. See Rust's
|
||||
/// `ShieldStateCode` for more information about the meaning of the cases.
|
||||
enum EncryptionAuthenticity: Hashable {
|
||||
enum Color { case red, gray }
|
||||
|
||||
case notGuaranteed(color: Color)
|
||||
case unknownDevice(color: Color)
|
||||
case unsignedDevice(color: Color)
|
||||
case unverifiedIdentity(color: Color)
|
||||
case sentInClear(color: Color)
|
||||
|
||||
var message: String {
|
||||
switch self {
|
||||
case .notGuaranteed:
|
||||
L10n.eventShieldReasonAuthenticityNotGuaranteed
|
||||
case .unknownDevice:
|
||||
L10n.eventShieldReasonUnknownDevice
|
||||
case .unsignedDevice:
|
||||
L10n.eventShieldReasonUnsignedDevice
|
||||
case .unverifiedIdentity:
|
||||
L10n.eventShieldReasonUnverifiedIdentity
|
||||
case .sentInClear:
|
||||
L10n.eventShieldReasonSentInClear
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension EncryptionAuthenticity {
|
||||
init?(shieldState: ShieldState) {
|
||||
switch shieldState {
|
||||
case .red(let code, _):
|
||||
self.init(shieldStateCode: code, color: .red)
|
||||
case .grey(let code, _):
|
||||
self.init(shieldStateCode: code, color: .gray)
|
||||
case .none:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
init(shieldStateCode: ShieldStateCode, color: EncryptionAuthenticity.Color) {
|
||||
switch shieldStateCode {
|
||||
case .authenticityNotGuaranteed:
|
||||
self = .notGuaranteed(color: color)
|
||||
case .unknownDevice:
|
||||
self = .unknownDevice(color: color)
|
||||
case .unsignedDevice:
|
||||
self = .unsignedDevice(color: color)
|
||||
case .unverifiedIdentity:
|
||||
self = .unverifiedIdentity(color: color)
|
||||
case .sentInClear:
|
||||
self = .sentInClear(color: color)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -24,6 +24,8 @@ struct RoomTimelineItemProperties: Hashable {
|
||||
var reactions: [AggregatedReaction] = []
|
||||
/// The delivery status for this item. If a sent message is echoed the value is nil.
|
||||
var deliveryStatus: TimelineItemDeliveryStatus?
|
||||
/// The read receipts of the item, ordered from newest to oldest
|
||||
/// The read receipts of the item, ordered from newest to oldest.
|
||||
var orderedReadReceipts: [ReadReceipt] = []
|
||||
/// Authenticity warnings for item's sent in encrypted rooms.
|
||||
var encryptionAuthenticity: EncryptionAuthenticity?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user