@@ -556,7 +556,6 @@ extension RemoteDataSource {
556556 system. dateSent = Date ( )
557557
558558 system. recipientID = QBSession . current. currentUserID
559- // await stream.process(system)
560559
561560 for id in dto. participantsIds {
562561 system. recipientID = UInt ( id) ?? 0
@@ -893,6 +892,7 @@ extension RemoteDataSource {
893892
894893 let fileName = blob. name ?? " file "
895894 let fileId = String ( blob. id)
895+ let fileUID = blob. uid ?? " "
896896
897897 var fileExtension : FileExtension
898898 if let extStr = fileName. components ( separatedBy: " . " ) . last,
@@ -916,7 +916,8 @@ extension RemoteDataSource {
916916 name: fileName,
917917 type: fileExtension. type,
918918 data: dto. data,
919- path: filePath)
919+ path: filePath,
920+ uid: fileUID)
920921 } catch let nsError as NSError {
921922 throw try nsError. convertToRemoteException ( )
922923 } catch {
@@ -974,6 +975,7 @@ extension RemoteDataSource {
974975 uploaded. name = fileName
975976 uploaded. type = fileExtension. type
976977 uploaded. path = filePath
978+ uploaded. uid = uuid
977979 return uploaded
978980 } catch let nsError as NSError {
979981 throw try nsError. convertToRemoteException ( )
@@ -982,6 +984,10 @@ extension RemoteDataSource {
982984 }
983985 } else {
984986 var uploaded = try await get ( fileWithPath: dto. id)
987+ if uploaded. name. contains ( " json " ) , uploaded. ext != . json {
988+ uploaded. name = uploaded. name. replacingOccurrences ( of: " json " ,
989+ with: uploaded. ext. rawValue)
990+ }
985991 if dto. name. contains ( dto. ext. rawValue) {
986992 let fileName = dto. name. replacingOccurrences ( of: dto. ext. rawValue,
987993 with: " " )
@@ -1425,7 +1431,8 @@ private extension QBRequest {
14251431 name: fileName,
14261432 type: fileExt. type,
14271433 data: data,
1428- path: filePath)
1434+ path: filePath,
1435+ uid: uuid ?? " " )
14291436 }
14301437
14311438 static func delete( file id: UInt ) async throws {
@@ -1645,7 +1652,9 @@ extension QBChatMessage {
16451652 }
16461653
16471654 attachments = value. filesInfo. compactMap {
1648- return QBChatAttachment ( $0)
1655+ var attachment = QBChatAttachment ( $0)
1656+ attachment [ " uid " ] = $0. uid
1657+ return attachment
16491658 }
16501659
16511660 delayed = value. delayed
@@ -1658,15 +1667,26 @@ extension QBChatMessage {
16581667
16591668private extension RemoteFileInfoDTO {
16601669 init ( _ value: QBChatAttachment ) throws {
1661- guard let id = value. id else {
1662- let info = " \( String ( describing: QBChatAttachment . self) ) id is missing "
1663- throw MapperException . incorrectData ( description: info)
1670+ if let id = value. id {
1671+ self . id = id
1672+ } else {
1673+ if let urlPath = value. url, let url = URL ( string: urlPath) {
1674+ self . id = url. lastPathComponent
1675+ }
1676+ if let uid = value. customParameters ? [ " uid " ] {
1677+ self . id = uid
1678+ }
1679+ if let contentType = value [ " content-type " ] {
1680+ type = contentType
1681+ }
16641682 }
1665- self . id = id
16661683
16671684 name = value. name ?? " "
16681685 type = value. type ?? " "
16691686 path = value. url ?? " "
1687+ if let uid = value. customParameters ? [ " uid " ] {
1688+ self . uid = uid
1689+ }
16701690 }
16711691}
16721692
0 commit comments