ui: optionally encrypt received SMP files (#3095)

This commit is contained in:
Evgeny Poberezkin 2023-09-21 19:02:47 +01:00 committed by GitHub
parent b7c562fb10
commit cb10f8b080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 6 deletions

View File

@ -84,7 +84,7 @@ struct CIFileView: View {
Task {
logger.debug("CIFileView fileAction - in .rcvInvitation, in Task")
if let user = ChatModel.shared.currentUser {
let encrypted = file.fileProtocol == .xftp && privacyEncryptLocalFilesGroupDefault.get()
let encrypted = privacyEncryptLocalFilesGroupDefault.get()
await receiveFile(user: user, fileId: file.fileId, encrypted: encrypted)
}
}

View File

@ -383,7 +383,7 @@ func apiSetFileToReceive(fileId: Int64, encrypted: Bool) {
func autoReceiveFile(_ file: CIFile, encrypted: Bool) -> ChatItem? {
switch file.fileProtocol {
case .smp:
return apiReceiveFile(fileId: file.fileId, encrypted: false)?.chatItem
return apiReceiveFile(fileId: file.fileId, encrypted: encrypted)?.chatItem
case .xftp:
apiSetFileToReceive(fileId: file.fileId, encrypted: encrypted)
return nil

View File

@ -2144,7 +2144,6 @@ public struct ChatItem: Identifiable, Decodable {
}
public var encryptLocalFile: Bool {
file?.fileProtocol == .xftp &&
content.msgContent?.isVideo == false &&
privacyEncryptLocalFilesGroupDefault.get()
}

View File

@ -1416,8 +1416,7 @@ data class ChatItem (
val encryptedFile: Boolean? = if (file?.fileSource == null) null else file.fileSource.cryptoArgs != null
val encryptLocalFile: Boolean
get() = file?.fileProtocol == FileProtocol.XFTP &&
content.msgContent !is MsgContent.MCVideo &&
get() = content.msgContent !is MsgContent.MCVideo &&
chatController.appPrefs.privacyEncryptLocalFiles.get()
val memberDisplayName: String? get() =

View File

@ -71,7 +71,7 @@ fun CIFileView(
when (file.fileStatus) {
is CIFileStatus.RcvInvitation -> {
if (fileSizeValid()) {
val encrypted = file.fileProtocol == FileProtocol.XFTP && chatController.appPrefs.privacyEncryptLocalFiles.get()
val encrypted = chatController.appPrefs.privacyEncryptLocalFiles.get()
receiveFile(file.fileId, encrypted)
} else {
AlertManager.shared.showAlertMsg(