Disable chatroom when it is not secure

This commit is contained in:
Benoit Martins 2026-02-23 15:49:02 +01:00
parent 23f5211131
commit d39e4a0e34
4 changed files with 50 additions and 39 deletions

View file

@ -2,6 +2,6 @@ import Foundation
public enum AppGitInfo {
public static let branch = "master"
public static let commit = "1fff8d6d3"
public static let commit = "23f521113"
public static let tag = "6.1.0-alpha"
}

View file

@ -458,41 +458,41 @@ struct ConversationFragment: View {
.padding(.all, 10)
}
}
Button {
isMenuOpen = false
withAnimation {
isShowMediaFilesFragment = true
}
} label: {
HStack {
Text("conversation_menu_media_files")
Spacer()
Image("image")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
.padding(.all, 10)
}
}
Button {
isMenuOpen = false
withAnimation {
isShowMediaFilesFragment = true
}
Button {
isMenuOpen = false
withAnimation {
isShowDocumentsFilesFragment = true
}
} label: {
HStack {
Text("conversation_menu_documents_files")
Spacer()
Image("file-pdf")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
.padding(.all, 10)
}
} label: {
HStack {
Text("conversation_menu_media_files")
Spacer()
Image("image")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
.padding(.all, 10)
}
}
Button {
isMenuOpen = false
withAnimation {
isShowDocumentsFilesFragment = true
}
} label: {
HStack {
Text("conversation_menu_documents_files")
Spacer()
Image("file-pdf")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
.padding(.all, 10)
}
}
} label: {

View file

@ -30,7 +30,7 @@ class ConversationModel: ObservableObject, Identifiable {
var chatRoom: ChatRoom
var lastMessage: ChatMessage?
let isDisabledBecauseNotSecured: Bool = false
var isDisabledBecauseNotSecured: Bool = false
static let TAG = "[Conversation Model]"
@ -68,8 +68,19 @@ class ConversationModel: ObservableObject, Identifiable {
self.remoteSipUri = chatRoom.peerAddress?.asStringUriOnly() ?? ""
self.isGroup = !chatRoom.hasCapability(mask: ChatRoom.Capabilities.OneToOne.rawValue) && chatRoom.hasCapability(mask: ChatRoom.Capabilities.Conference.rawValue)
if (!chatRoom.hasCapability(mask: ChatRoom.Capabilities.Encrypted.rawValue)) {
if let localAddress = chatRoom.localAddress , LinphoneUtils.getAccountForAddress(address: localAddress)?.params?.instantMessagingEncryptionMandatory == true {
Log.warn("\(ConversationModel.TAG) Conversation with subject \(chatRoom.subjectUtf8 ?? "No subject") is considered as read-only because it isn't encrypted and default account is in secure mode")
self.isDisabledBecauseNotSecured = true
} else {
self.isDisabledBecauseNotSecured = false
}
} else {
self.isDisabledBecauseNotSecured = false
}
self.isReadOnly = chatRoom.isReadOnly
self.isReadOnly = chatRoom.isReadOnly || self.isDisabledBecauseNotSecured
let chatRoomParticipants = chatRoom.participants
let addressFriend = (chatRoomParticipants.first != nil && chatRoomParticipants.first!.address != nil)

View file

@ -161,7 +161,7 @@ class ConversationViewModel: ObservableObject {
if displayedConversation.isGroup {
self.getEventMessage(eventLog: eventLog)
}
let isReadOnly = chatRoom.isReadOnly
let isReadOnly = chatRoom.isReadOnly || displayedConversation.isDisabledBecauseNotSecured
DispatchQueue.main.async {
displayedConversation.isReadOnly = isReadOnly
}
@ -171,7 +171,7 @@ class ConversationViewModel: ObservableObject {
if displayedConversation.isGroup {
self.getEventMessage(eventLog: eventLog)
}
let isReadOnly = chatRoom.isReadOnly
let isReadOnly = chatRoom.isReadOnly || displayedConversation.isDisabledBecauseNotSecured
DispatchQueue.main.async {
displayedConversation.isReadOnly = isReadOnly
}