From 82b8883bb14276260436cac44e1d40f8784727b9 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Tue, 9 Mar 2021 11:16:43 +1100 Subject: [PATCH] fix sending quote --- .../messaging/messages/visible/Quote.kt | 3 +-- .../messaging/messages/visible/VisibleMessage.kt | 16 ++-------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/visible/Quote.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/visible/Quote.kt index 1f89b37c12..e1255c6ef0 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/visible/Quote.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/visible/Quote.kt @@ -84,8 +84,7 @@ class Quote() { } val quotedAttachmentProto = SignalServiceProtos.DataMessage.Quote.QuotedAttachment.newBuilder() quotedAttachmentProto.contentType = attachment.contentType - val fileName = attachment.fileName?.get() - fileName?.let { quotedAttachmentProto.fileName = fileName } + if (attachment.fileName.isPresent) quotedAttachmentProto.fileName = attachment.fileName.get() quotedAttachmentProto.thumbnail = Attachment.createAttachmentPointer(attachment) try { quoteProto.addAttachments(quotedAttachmentProto.build()) diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/visible/VisibleMessage.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/visible/VisibleMessage.kt index 692daab194..d353886eec 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/visible/VisibleMessage.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/visible/VisibleMessage.kt @@ -81,25 +81,13 @@ class VisibleMessage : Message() { // Text text?.let { dataMessage.body = text } // Quote - val quotedAttachmentID = quote?.attachmentID - quotedAttachmentID?.let { - val index = attachmentIDs.indexOf(quotedAttachmentID) - if (index >= 0) { attachmentIDs.removeAt(index) } - } - val quote = quote quote?.let { - val quoteProto = quote.toProto() + val quoteProto = it.toProto() if (quoteProto != null) dataMessage.quote = quoteProto } //Link preview - val linkPreviewAttachmentID = linkPreview?.attachmentID - linkPreviewAttachmentID?.let { - val index = attachmentIDs.indexOf(quotedAttachmentID) - if (index >= 0) { attachmentIDs.removeAt(index) } - } - val linkPreview = linkPreview linkPreview?.let { - val linkPreviewProto = linkPreview.toProto() + val linkPreviewProto = it.toProto() linkPreviewProto?.let { dataMessage.addAllPreview(listOf(linkPreviewProto)) }