mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 03:48:27 +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:
@@ -256,6 +256,7 @@
|
||||
"error_some_messages_have_not_been_sent" = "Some messages have not been sent";
|
||||
"error_unknown" = "Sorry, an error occurred";
|
||||
"event_shield_reason_authenticity_not_guaranteed" = "The authenticity of this encrypted message can't be guaranteed on this device.";
|
||||
"event_shield_reason_sent_in_clear" = "Sent in clear.";
|
||||
"event_shield_reason_unknown_device" = "Encrypted by an unknown or deleted device.";
|
||||
"event_shield_reason_unsigned_device" = "Encrypted by a device not verified by its owner.";
|
||||
"event_shield_reason_unverified_identity" = "Encrypted by an unverified user.";
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
/* Used for testing */
|
||||
"untranslated" = "Untranslated";
|
||||
|
||||
// MARK: - Shields
|
||||
|
||||
"send_info_not_encrypted" = "Not encrypted";
|
||||
|
||||
// MARK: - Soft logout
|
||||
|
||||
"soft_logout_signin_title" = "Sign in";
|
||||
|
||||
@@ -47,6 +47,7 @@ final class AppSettings {
|
||||
case publicSearchEnabled
|
||||
case fuzzyRoomListSearchEnabled
|
||||
case pinningEnabled
|
||||
case timelineItemAuthenticityEnabled
|
||||
}
|
||||
|
||||
private static var suiteName: String = InfoPlistReader.main.appGroupIdentifier
|
||||
@@ -284,6 +285,9 @@ final class AppSettings {
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.pinningEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var pinningEnabled
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.timelineItemAuthenticityEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var timelineItemAuthenticityEnabled
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -540,6 +540,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let userID = userSession.clientProxy.userID
|
||||
|
||||
let timelineItemFactory = RoomTimelineItemFactory(userID: userID,
|
||||
encryptionAuthenticityEnabled: appSettings.timelineItemAuthenticityEnabled,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID))
|
||||
|
||||
@@ -1033,6 +1034,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
let userID = userSession.clientProxy.userID
|
||||
|
||||
let timelineItemFactory = RoomTimelineItemFactory(userID: userID,
|
||||
encryptionAuthenticityEnabled: appSettings.timelineItemAuthenticityEnabled,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID))
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ import Foundation
|
||||
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
|
||||
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
|
||||
internal enum UntranslatedL10n {
|
||||
/// Not encrypted
|
||||
internal static var sendInfoNotEncrypted: String { return UntranslatedL10n.tr("Untranslated", "send_info_not_encrypted") }
|
||||
/// Clear all data currently stored on this device?
|
||||
/// Sign in again to access your account data and messages.
|
||||
internal static var softLogoutClearDataDialogContent: String { return UntranslatedL10n.tr("Untranslated", "soft_logout_clear_data_dialog_content") }
|
||||
|
||||
@@ -570,6 +570,8 @@ internal enum L10n {
|
||||
internal static var errorUnknown: String { return L10n.tr("Localizable", "error_unknown") }
|
||||
/// The authenticity of this encrypted message can't be guaranteed on this device.
|
||||
internal static var eventShieldReasonAuthenticityNotGuaranteed: String { return L10n.tr("Localizable", "event_shield_reason_authenticity_not_guaranteed") }
|
||||
/// Sent in clear.
|
||||
internal static var eventShieldReasonSentInClear: String { return L10n.tr("Localizable", "event_shield_reason_sent_in_clear") }
|
||||
/// Encrypted by an unknown or deleted device.
|
||||
internal static var eventShieldReasonUnknownDevice: String { return L10n.tr("Localizable", "event_shield_reason_unknown_device") }
|
||||
/// Encrypted by a device not verified by its owner.
|
||||
|
||||
@@ -330,6 +330,8 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
||||
.previewDisplayName("Replies")
|
||||
threads
|
||||
.previewDisplayName("Thread decorator")
|
||||
encryptionAuthenticity
|
||||
.previewDisplayName("Encryption Indicators")
|
||||
}
|
||||
|
||||
// These akwats include a reply
|
||||
@@ -477,4 +479,80 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
||||
}
|
||||
.environmentObject(viewModel.context)
|
||||
}
|
||||
|
||||
static var encryptionAuthenticity: some View {
|
||||
VStack(spacing: 0) {
|
||||
RoomTimelineItemView(viewState: .init(item: TextRoomTimelineItem(id: .init(timelineID: ""),
|
||||
timestamp: "10:42",
|
||||
isOutgoing: true,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: false,
|
||||
sender: .init(id: "whoever"),
|
||||
content: .init(body: "A long message that should be on multiple lines."),
|
||||
properties: RoomTimelineItemProperties(encryptionAuthenticity: .unsignedDevice(color: .red))),
|
||||
groupStyle: .single))
|
||||
|
||||
RoomTimelineItemView(viewState: .init(item: TextRoomTimelineItem(id: .init(timelineID: ""),
|
||||
timestamp: "10:42",
|
||||
isOutgoing: true,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: false,
|
||||
sender: .init(id: "whoever"),
|
||||
content: .init(body: "A long message that should be on multiple lines."),
|
||||
properties: RoomTimelineItemProperties(isEdited: true,
|
||||
encryptionAuthenticity: .unsignedDevice(color: .red))),
|
||||
groupStyle: .single))
|
||||
|
||||
RoomTimelineItemView(viewState: .init(item: TextRoomTimelineItem(id: .init(timelineID: ""),
|
||||
timestamp: "10:42",
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: false,
|
||||
sender: .init(id: "whoever"),
|
||||
content: .init(body: "Short message"),
|
||||
properties: RoomTimelineItemProperties(encryptionAuthenticity: .unknownDevice(color: .red))),
|
||||
groupStyle: .first))
|
||||
|
||||
RoomTimelineItemView(viewState: .init(item: TextRoomTimelineItem(id: .init(timelineID: ""),
|
||||
timestamp: "10:42",
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: false,
|
||||
sender: .init(id: "whoever"),
|
||||
content: .init(body: "Message goes Here"),
|
||||
properties: RoomTimelineItemProperties(encryptionAuthenticity: .notGuaranteed(color: .gray))),
|
||||
groupStyle: .last))
|
||||
|
||||
ImageRoomTimelineView(timelineItem: ImageRoomTimelineItem(id: .random,
|
||||
timestamp: "Now",
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: false,
|
||||
sender: .init(id: "Bob"),
|
||||
content: .init(body: "Some other image", source: MediaSourceProxy(url: .picturesDirectory, mimeType: "image/png"), thumbnailSource: nil),
|
||||
|
||||
properties: RoomTimelineItemProperties(encryptionAuthenticity: .notGuaranteed(color: .gray))))
|
||||
|
||||
VoiceMessageRoomTimelineView(timelineItem: .init(id: .init(timelineID: ""),
|
||||
timestamp: "10:42",
|
||||
isOutgoing: true,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
isThreaded: true,
|
||||
sender: .init(id: ""),
|
||||
content: .init(body: "audio.ogg",
|
||||
duration: 100,
|
||||
waveform: EstimatedWaveform.mockWaveform,
|
||||
source: nil,
|
||||
contentType: nil),
|
||||
properties: RoomTimelineItemProperties(encryptionAuthenticity: .notGuaranteed(color: .gray))),
|
||||
playerState: AudioPlayerState(id: .timelineItemIdentifier(.random), duration: 10, waveform: EstimatedWaveform.mockWaveform))
|
||||
}
|
||||
.environmentObject(viewModel.context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,17 @@ private struct TimelineItemSendInfoLabel: View {
|
||||
|
||||
var statusIcon: KeyPath<CompoundIcons, Image>? {
|
||||
switch sendInfo.status {
|
||||
case .sendingFailed: \.error
|
||||
case .unverifiedSession, .authenticityUnknown: \.admin
|
||||
case .unencrypted: \.keyOff
|
||||
case .none: nil
|
||||
case .sendingFailed:
|
||||
\.error
|
||||
case .encryptionAuthenticity(.notGuaranteed):
|
||||
\.infoSolid
|
||||
case .encryptionAuthenticity(.unknownDevice),
|
||||
.encryptionAuthenticity(.unsignedDevice),
|
||||
.encryptionAuthenticity(.unverifiedIdentity),
|
||||
.encryptionAuthenticity(.sentInClear):
|
||||
\.lockOff
|
||||
case .none:
|
||||
nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +74,7 @@ private struct TimelineItemSendInfoLabel: View {
|
||||
case .sendingFailed: L10n.commonSendingFailed
|
||||
case .none: nil
|
||||
// Temporary testing strings.
|
||||
case .unverifiedSession: L10n.eventShieldReasonUnsignedDevice
|
||||
case .authenticityUnknown: L10n.eventShieldReasonAuthenticityNotGuaranteed
|
||||
case .unencrypted: UntranslatedL10n.sendInfoNotEncrypted
|
||||
case .encryptionAuthenticity(let authenticity): authenticity.message
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +116,7 @@ private struct TimelineItemSendInfoLabel: View {
|
||||
|
||||
/// All the data needed to render a timeline item's send info label.
|
||||
private struct TimelineItemSendInfo {
|
||||
enum Status { case sendingFailed, unverifiedSession, authenticityUnknown, unencrypted }
|
||||
enum Status { case sendingFailed, encryptionAuthenticity(EncryptionAuthenticity) }
|
||||
|
||||
/// Describes how the content and the send info should be arranged inside a bubble
|
||||
enum LayoutType {
|
||||
@@ -126,9 +131,11 @@ private struct TimelineItemSendInfo {
|
||||
|
||||
var foregroundStyle: Color {
|
||||
switch status {
|
||||
case .sendingFailed, .unverifiedSession:
|
||||
case .sendingFailed:
|
||||
.compound.textCriticalPrimary
|
||||
case .authenticityUnknown, .unencrypted, .none:
|
||||
case .encryptionAuthenticity(let authenticity):
|
||||
authenticity.foregroundStyle
|
||||
case .none:
|
||||
.compound.textSecondary
|
||||
}
|
||||
}
|
||||
@@ -140,6 +147,8 @@ private extension TimelineItemSendInfo {
|
||||
|
||||
status = if adjustedDeliveryStatus == .sendingFailed {
|
||||
.sendingFailed
|
||||
} else if let authenticity = timelineItem.properties.encryptionAuthenticity {
|
||||
.encryptionAuthenticity(authenticity)
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
@@ -161,6 +170,24 @@ private extension TimelineItemSendInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private extension EncryptionAuthenticity {
|
||||
var foregroundStyle: SwiftUI.Color {
|
||||
switch self {
|
||||
case .notGuaranteed(let color),
|
||||
.unknownDevice(let color),
|
||||
.unsignedDevice(let color),
|
||||
.unverifiedIdentity(let color),
|
||||
.sentInClear(let color):
|
||||
switch color {
|
||||
case .red:
|
||||
.compound.textCriticalPrimary
|
||||
case .gray:
|
||||
.compound.textSecondary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct TimelineItemSendInfoLabel_Previews: PreviewProvider, TestablePreview {
|
||||
@@ -172,14 +199,14 @@ struct TimelineItemSendInfoLabel_Previews: PreviewProvider, TestablePreview {
|
||||
status: .sendingFailed,
|
||||
layoutType: .horizontal()))
|
||||
TimelineItemSendInfoLabel(sendInfo: .init(localizedString: "09:47 AM",
|
||||
status: .unverifiedSession,
|
||||
status: .encryptionAuthenticity(.unsignedDevice(color: .red)),
|
||||
layoutType: .horizontal()))
|
||||
TimelineItemSendInfoLabel(sendInfo: .init(localizedString: "09:47 AM",
|
||||
status: .authenticityUnknown,
|
||||
layoutType: .horizontal()))
|
||||
TimelineItemSendInfoLabel(sendInfo: .init(localizedString: "09:47 AM",
|
||||
status: .unencrypted,
|
||||
status: .encryptionAuthenticity(.notGuaranteed(color: .gray)),
|
||||
layoutType: .horizontal()))
|
||||
// TimelineItemSendInfoLabel(sendInfo: .init(localizedString: "09:47 AM",
|
||||
// status: .unencrypted,
|
||||
// layoutType: .horizontal()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var elementCallBaseURLOverride: URL? { get set }
|
||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||
var pinningEnabled: Bool { get set }
|
||||
var timelineItemAuthenticityEnabled: Bool { get set }
|
||||
}
|
||||
|
||||
extension AppSettings: DeveloperOptionsProtocol { }
|
||||
|
||||
+7
@@ -50,6 +50,13 @@ struct DeveloperOptionsScreen: View {
|
||||
Text("Fuzzy searching")
|
||||
}
|
||||
}
|
||||
|
||||
Section("Encryption") {
|
||||
Toggle(isOn: $context.timelineItemAuthenticityEnabled) {
|
||||
Text("Message authenticity warnings")
|
||||
Text("Requires app reboot")
|
||||
}
|
||||
}
|
||||
|
||||
Section("Element Call") {
|
||||
TextField(context.viewState.elementCallBaseURL.absoluteString, text: $elementCallBaseURLString)
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
@@ -120,7 +120,9 @@ class EventTimelineItemProxy {
|
||||
let debugInfo = item.debugInfo()
|
||||
return TimelineItemDebugInfo(model: debugInfo.model, originalJSON: debugInfo.originalJson, latestEditJSON: debugInfo.latestEditJson)
|
||||
}()
|
||||
|
||||
|
||||
lazy var shieldState = item.getShield(strict: false)
|
||||
|
||||
lazy var readReceipts = item.readReceipts()
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -50,7 +50,11 @@ extension EventBasedTimelineItemProtocol {
|
||||
var pollIfAvailable: Poll? {
|
||||
(self as? PollRoomTimelineItem)?.poll
|
||||
}
|
||||
|
||||
|
||||
var hasStatusIcon: Bool {
|
||||
hasFailedToSend || properties.encryptionAuthenticity != nil
|
||||
}
|
||||
|
||||
var hasFailedToSend: Bool {
|
||||
properties.deliveryStatus == .sendingFailed
|
||||
}
|
||||
@@ -74,8 +78,8 @@ extension EventBasedTimelineItemProtocol {
|
||||
whiteSpaces += 1
|
||||
}
|
||||
|
||||
// To account for the extra spacing created by the alert icon
|
||||
if hasFailedToSend {
|
||||
// To account for the extra spacing created by the status icon
|
||||
if hasStatusIcon {
|
||||
whiteSpaces += 3
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,14 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
|
||||
/// The Matrix ID of the current user.
|
||||
private let userID: String
|
||||
private let encryptionAuthenticityEnabled: Bool
|
||||
|
||||
init(userID: String,
|
||||
encryptionAuthenticityEnabled: Bool,
|
||||
attributedStringBuilder: AttributedStringBuilderProtocol,
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder) {
|
||||
self.userID = userID
|
||||
self.encryptionAuthenticityEnabled = encryptionAuthenticityEnabled
|
||||
self.attributedStringBuilder = attributedStringBuilder
|
||||
self.stateEventStringBuilder = stateEventStringBuilder
|
||||
}
|
||||
@@ -156,7 +159,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
blurhash: imageInfo.blurhash,
|
||||
properties: RoomTimelineItemProperties(reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildEncryptedTimelineItem(_ eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -220,7 +224,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildImageTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -240,7 +245,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildVideoTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -260,7 +266,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildAudioTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -280,7 +287,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildVoiceTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -300,7 +308,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildFileTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -320,7 +329,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildNoticeTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -340,7 +350,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildEmoteTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -360,7 +371,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildLocationTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
@@ -380,7 +392,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: messageTimelineItem.isEdited(),
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
// swiftlint:disable:next function_parameter_count
|
||||
@@ -429,7 +442,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
properties: RoomTimelineItemProperties(isEdited: edited,
|
||||
reactions: aggregateReactions(eventItemProxy.reactions),
|
||||
deliveryStatus: eventItemProxy.deliveryStatus,
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts)))
|
||||
orderedReadReceipts: orderReadReceipts(eventItemProxy.readReceipts),
|
||||
encryptionAuthenticity: authenticity(eventItemProxy.shieldState)))
|
||||
}
|
||||
|
||||
private func buildCallInviteTimelineItem(for eventItemProxy: EventTimelineItemProxy) -> RoomTimelineItemProtocol {
|
||||
@@ -488,6 +502,11 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func authenticity(_ shieldState: ShieldState?) -> EncryptionAuthenticity? {
|
||||
guard encryptionAuthenticityEnabled else { return nil }
|
||||
return shieldState.flatMap(EncryptionAuthenticity.init)
|
||||
}
|
||||
|
||||
// MARK: - Message events content
|
||||
|
||||
private func buildTextTimelineItemContent(_ messageContent: TextMessageContent) -> TextRoomTimelineItemContent {
|
||||
|
||||
@@ -636,6 +636,7 @@ class MockScreen: Identifiable {
|
||||
let timelineController = RoomTimelineController(roomProxy: roomProxy,
|
||||
initialFocussedEventID: nil,
|
||||
timelineItemFactory: RoomTimelineItemFactory(userID: "@alice:matrix.org",
|
||||
encryptionAuthenticityEnabled: true,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder(userID: "@alice:matrix.org")),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
|
||||
Reference in New Issue
Block a user