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 {
isMenuOpen = false Button {
withAnimation { isMenuOpen = false
isShowMediaFilesFragment = true 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)
}
} }
} label: {
Button { HStack {
isMenuOpen = false Text("conversation_menu_media_files")
withAnimation { Spacer()
isShowDocumentsFilesFragment = true Image("image")
} .renderingMode(.template)
} label: { .resizable()
HStack { .foregroundStyle(Color.grayMain2c500)
Text("conversation_menu_documents_files") .frame(width: 25, height: 25, alignment: .leading)
Spacer() .padding(.all, 10)
Image("file-pdf") }
.renderingMode(.template) }
.resizable()
.foregroundStyle(Color.grayMain2c500) Button {
.frame(width: 25, height: 25, alignment: .leading) isMenuOpen = false
.padding(.all, 10) 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: { } 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]"
@ -68,8 +68,19 @@ class ConversationModel: ObservableObject, Identifiable {
self.remoteSipUri = chatRoom.peerAddress?.asStringUriOnly() ?? "" self.remoteSipUri = chatRoom.peerAddress?.asStringUriOnly() ?? ""
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)
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 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
} }