ui: optionally encrypt received SMP files (#3095)
This commit is contained in:
parent
b7c562fb10
commit
cb10f8b080
@ -84,7 +84,7 @@ struct CIFileView: View {
|
|||||||
Task {
|
Task {
|
||||||
logger.debug("CIFileView fileAction - in .rcvInvitation, in Task")
|
logger.debug("CIFileView fileAction - in .rcvInvitation, in Task")
|
||||||
if let user = ChatModel.shared.currentUser {
|
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)
|
await receiveFile(user: user, fileId: file.fileId, encrypted: encrypted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ func apiSetFileToReceive(fileId: Int64, encrypted: Bool) {
|
|||||||
func autoReceiveFile(_ file: CIFile, encrypted: Bool) -> ChatItem? {
|
func autoReceiveFile(_ file: CIFile, encrypted: Bool) -> ChatItem? {
|
||||||
switch file.fileProtocol {
|
switch file.fileProtocol {
|
||||||
case .smp:
|
case .smp:
|
||||||
return apiReceiveFile(fileId: file.fileId, encrypted: false)?.chatItem
|
return apiReceiveFile(fileId: file.fileId, encrypted: encrypted)?.chatItem
|
||||||
case .xftp:
|
case .xftp:
|
||||||
apiSetFileToReceive(fileId: file.fileId, encrypted: encrypted)
|
apiSetFileToReceive(fileId: file.fileId, encrypted: encrypted)
|
||||||
return nil
|
return nil
|
||||||
|
@ -2144,7 +2144,6 @@ public struct ChatItem: Identifiable, Decodable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var encryptLocalFile: Bool {
|
public var encryptLocalFile: Bool {
|
||||||
file?.fileProtocol == .xftp &&
|
|
||||||
content.msgContent?.isVideo == false &&
|
content.msgContent?.isVideo == false &&
|
||||||
privacyEncryptLocalFilesGroupDefault.get()
|
privacyEncryptLocalFilesGroupDefault.get()
|
||||||
}
|
}
|
||||||
|
@ -1416,8 +1416,7 @@ data class ChatItem (
|
|||||||
val encryptedFile: Boolean? = if (file?.fileSource == null) null else file.fileSource.cryptoArgs != null
|
val encryptedFile: Boolean? = if (file?.fileSource == null) null else file.fileSource.cryptoArgs != null
|
||||||
|
|
||||||
val encryptLocalFile: Boolean
|
val encryptLocalFile: Boolean
|
||||||
get() = file?.fileProtocol == FileProtocol.XFTP &&
|
get() = content.msgContent !is MsgContent.MCVideo &&
|
||||||
content.msgContent !is MsgContent.MCVideo &&
|
|
||||||
chatController.appPrefs.privacyEncryptLocalFiles.get()
|
chatController.appPrefs.privacyEncryptLocalFiles.get()
|
||||||
|
|
||||||
val memberDisplayName: String? get() =
|
val memberDisplayName: String? get() =
|
||||||
|
@ -71,7 +71,7 @@ fun CIFileView(
|
|||||||
when (file.fileStatus) {
|
when (file.fileStatus) {
|
||||||
is CIFileStatus.RcvInvitation -> {
|
is CIFileStatus.RcvInvitation -> {
|
||||||
if (fileSizeValid()) {
|
if (fileSizeValid()) {
|
||||||
val encrypted = file.fileProtocol == FileProtocol.XFTP && chatController.appPrefs.privacyEncryptLocalFiles.get()
|
val encrypted = chatController.appPrefs.privacyEncryptLocalFiles.get()
|
||||||
receiveFile(file.fileId, encrypted)
|
receiveFile(file.fileId, encrypted)
|
||||||
} else {
|
} else {
|
||||||
AlertManager.shared.showAlertMsg(
|
AlertManager.shared.showAlertMsg(
|
||||||
|
Loading…
Reference in New Issue
Block a user