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 enum AppGitInfo {
public static let branch = "master" public static let branch = "master"
public static let commit = "1fff8d6d3" public static let commit = "23f521113"
public static let tag = "6.1.0-alpha" public static let tag = "6.1.0-alpha"
} }

View file

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

View file

@ -30,7 +30,7 @@ class ConversationModel: ObservableObject, Identifiable {
var chatRoom: ChatRoom var chatRoom: ChatRoom
var lastMessage: ChatMessage? var lastMessage: ChatMessage?
let isDisabledBecauseNotSecured: Bool = false var isDisabledBecauseNotSecured: Bool = false
static let TAG = "[Conversation Model]" static let TAG = "[Conversation Model]"
@ -69,7 +69,18 @@ class ConversationModel: ObservableObject, Identifiable {
self.isGroup = !chatRoom.hasCapability(mask: ChatRoom.Capabilities.OneToOne.rawValue) && chatRoom.hasCapability(mask: ChatRoom.Capabilities.Conference.rawValue) self.isGroup = !chatRoom.hasCapability(mask: ChatRoom.Capabilities.OneToOne.rawValue) && chatRoom.hasCapability(mask: ChatRoom.Capabilities.Conference.rawValue)
self.isReadOnly = chatRoom.isReadOnly 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.isDisabledBecauseNotSecured
let chatRoomParticipants = chatRoom.participants let chatRoomParticipants = chatRoom.participants
let addressFriend = (chatRoomParticipants.first != nil && chatRoomParticipants.first!.address != nil) let addressFriend = (chatRoomParticipants.first != nil && chatRoomParticipants.first!.address != nil)

View file

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