fix sending link preview to open group

This commit is contained in:
Ryan ZHAO 2021-03-09 16:15:39 +11:00
parent 70a7182320
commit d85ad12352

View file

@ -26,7 +26,6 @@ data class OpenGroupMessage(
fun from(message: VisibleMessage, server: String): OpenGroupMessage? {
val storage = MessagingConfiguration.shared.storage
val userPublicKey = storage.getUserPublicKey() ?: return null
var attachmentIDs = message.attachmentIDs
// Validation
if (!message.isValid()) { return null } // Should be valid at this point
// Quote
@ -34,8 +33,6 @@ data class OpenGroupMessage(
val quote = message.quote
if (quote != null && quote.isValid()) {
val quotedMessageBody = quote.text ?: quote.timestamp!!.toString()
val quotedAttachmentID = quote.attachmentID
if (quotedAttachmentID != null) { attachmentIDs.remove(quotedAttachmentID) }
// FIXME: For some reason the server always returns a 500 if quotedMessageServerID is set...
Quote(quote.timestamp!!, quote.publicKey!!, quotedMessageBody, null)
} else {
@ -51,18 +48,18 @@ data class OpenGroupMessage(
linkPreview?.let {
if (!linkPreview.isValid()) { return@let }
val attachmentID = linkPreview.attachmentID ?: return@let
val attachment = MessagingConfiguration.shared.messageDataProvider.getAttachmentPointer(attachmentID) ?: return@let
val attachment = MessagingConfiguration.shared.messageDataProvider.getSignalAttachmentPointer(attachmentID) ?: return@let
val openGroupLinkPreview = Attachment(
Attachment.Kind.LinkPreview,
server,
attachment.id,
attachment.contentType!!,
attachment.size.get(),
attachment.fileName.get(),
attachment.fileName.orNull(),
0,
attachment.width,
attachment.height,
attachment.caption.get(),
attachment.caption.orNull(),
attachment.url,
linkPreview.url,
linkPreview.title)