Skip to content

Commit

Permalink
fix: decryption error for message sent via encrypted contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanmo226 committed Oct 25, 2024
1 parent 05d9b03 commit bf18d87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion FlowCrypt/Core/CoreTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ struct MsgBlock: Decodable {

struct AttMeta: Decodable {
let name: String
let data: String
let data: String?
let type: String
let length: Int
let url: String?
let treatAs: String?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,17 @@ extension MessageAttachment {
}

init?(attMeta: MsgBlock.AttMeta) {
guard let data = Data(base64Encoded: attMeta.data.data()) else {
if let urlString = attMeta.url, let url = URL(string: urlString) {
// Fetch data synchronously from the URL
if let urlData = try? Data(contentsOf: url) {
self.init(name: attMeta.name, data: urlData, mimeType: attMeta.type, treatAs: "encryptedFile")
return
}
return nil
}
guard let attData = attMeta.data, let data = Data(base64Encoded: attData.data()) else {
return nil
}

self.init(name: attMeta.name, data: data, mimeType: attMeta.type, treatAs: attMeta.treatAs)
}
}
Expand Down

0 comments on commit bf18d87

Please sign in to comment.