From d0ba22dc4fe696da5658406fd5acefe4b768fbbf Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 7 Mar 2023 15:48:27 +1100 Subject: [PATCH 1/3] fix retry sending attachments that are not downloaded --- .../Conversations/ConversationVC+Interaction.swift | 14 +++++++++++++- .../Database/Models/Attachment.swift | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index a8ca98c6d..6ab7495c2 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -1611,7 +1611,19 @@ extension ConversationVC: quotedAttachment.downloadUrl == Attachment.nonMediaQuoteFileId, let quotedInteraction = try? quote.originalInteraction.fetchOne(db) { - let attachment = try? quotedInteraction.attachments.fetchAll(db).first + let attachment: Attachment? = { + if let attachment = try? quotedInteraction.attachments.fetchAll(db).first { + return attachment + } + if + let linkPreview = try? quotedInteraction.linkPreview.fetchOne(db), + let linkPreviewAttachment = try? linkPreview.attachment.fetchOne(db) + { + return linkPreviewAttachment + } + + return nil + }() try quote.with( attachmentId: attachment?.cloneAsQuoteThumbnail()?.inserted(db).id ).update(db) diff --git a/SessionMessagingKit/Database/Models/Attachment.swift b/SessionMessagingKit/Database/Models/Attachment.swift index fc004c92e..ab5a4024c 100644 --- a/SessionMessagingKit/Database/Models/Attachment.swift +++ b/SessionMessagingKit/Database/Models/Attachment.swift @@ -883,9 +883,10 @@ extension Attachment { let cloneId: String = UUID().uuidString let thumbnailName: String = "quoted-thumbnail-\(sourceFilename ?? "null")" + guard self.isVisualMedia else { return nil } + guard self.isValid, - self.isVisualMedia, let thumbnailPath: String = Attachment.originalFilePath( id: cloneId, mimeType: OWSMimeTypeImageJpeg, From ee8008ff4ddacaa017a2fd5d66ee69419dbb8e47 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 7 Mar 2023 16:02:46 +1100 Subject: [PATCH 2/3] minor optimisation on fetching attachment from database --- Session/Conversations/ConversationVC+Interaction.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 6ab7495c2..037e39647 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -1612,7 +1612,7 @@ extension ConversationVC: let quotedInteraction = try? quote.originalInteraction.fetchOne(db) { let attachment: Attachment? = { - if let attachment = try? quotedInteraction.attachments.fetchAll(db).first { + if let attachment = try? quotedInteraction.attachments.fetchOne(db) { return attachment } if From 4af96fb841484c836c5f3657dcfcbbc1be7eb5e2 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 8 Mar 2023 11:45:33 +1100 Subject: [PATCH 3/3] update build number --- Session.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 95ecf73f0..32bd2af3c 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -6040,7 +6040,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6113,7 +6113,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -6179,7 +6179,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6253,7 +6253,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -7181,7 +7181,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7253,7 +7253,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 395; + CURRENT_PROJECT_VERSION = 396; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)",