mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 21:53:43 +00:00
fix sending link preview to open group
This commit is contained in:
parent
70a7182320
commit
d85ad12352
@ -26,7 +26,6 @@ data class OpenGroupMessage(
|
|||||||
fun from(message: VisibleMessage, server: String): OpenGroupMessage? {
|
fun from(message: VisibleMessage, server: String): OpenGroupMessage? {
|
||||||
val storage = MessagingConfiguration.shared.storage
|
val storage = MessagingConfiguration.shared.storage
|
||||||
val userPublicKey = storage.getUserPublicKey() ?: return null
|
val userPublicKey = storage.getUserPublicKey() ?: return null
|
||||||
var attachmentIDs = message.attachmentIDs
|
|
||||||
// Validation
|
// Validation
|
||||||
if (!message.isValid()) { return null } // Should be valid at this point
|
if (!message.isValid()) { return null } // Should be valid at this point
|
||||||
// Quote
|
// Quote
|
||||||
@ -34,8 +33,6 @@ data class OpenGroupMessage(
|
|||||||
val quote = message.quote
|
val quote = message.quote
|
||||||
if (quote != null && quote.isValid()) {
|
if (quote != null && quote.isValid()) {
|
||||||
val quotedMessageBody = quote.text ?: quote.timestamp!!.toString()
|
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...
|
// FIXME: For some reason the server always returns a 500 if quotedMessageServerID is set...
|
||||||
Quote(quote.timestamp!!, quote.publicKey!!, quotedMessageBody, null)
|
Quote(quote.timestamp!!, quote.publicKey!!, quotedMessageBody, null)
|
||||||
} else {
|
} else {
|
||||||
@ -51,18 +48,18 @@ data class OpenGroupMessage(
|
|||||||
linkPreview?.let {
|
linkPreview?.let {
|
||||||
if (!linkPreview.isValid()) { return@let }
|
if (!linkPreview.isValid()) { return@let }
|
||||||
val attachmentID = linkPreview.attachmentID ?: 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(
|
val openGroupLinkPreview = Attachment(
|
||||||
Attachment.Kind.LinkPreview,
|
Attachment.Kind.LinkPreview,
|
||||||
server,
|
server,
|
||||||
attachment.id,
|
attachment.id,
|
||||||
attachment.contentType!!,
|
attachment.contentType!!,
|
||||||
attachment.size.get(),
|
attachment.size.get(),
|
||||||
attachment.fileName.get(),
|
attachment.fileName.orNull(),
|
||||||
0,
|
0,
|
||||||
attachment.width,
|
attachment.width,
|
||||||
attachment.height,
|
attachment.height,
|
||||||
attachment.caption.get(),
|
attachment.caption.orNull(),
|
||||||
attachment.url,
|
attachment.url,
|
||||||
linkPreview.url,
|
linkPreview.url,
|
||||||
linkPreview.title)
|
linkPreview.title)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user