mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 20:18:26 +00:00
fix multi device attachment issue
This commit is contained in:
parent
d7c03c9d0a
commit
8bc6df5d16
@ -120,7 +120,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
val mmsDatabase = DatabaseFactory.getMmsDatabase(context)
|
||||
val insertResult = if (message.sender == getUserPublicKey()) {
|
||||
|
||||
val mediaMessage = OutgoingMediaMessage.from(message, targetRecipient, pointerAttachments, quote.orNull(), linkPreviews.orNull().firstOrNull())
|
||||
val mediaMessage = OutgoingMediaMessage.from(message, targetRecipient, pointerAttachments, quote.orNull(), linkPreviews.orNull()?.firstOrNull())
|
||||
mmsDatabase.beginTransaction()
|
||||
mmsDatabase.insertSecureDecryptedMessageOutbox(mediaMessage, message.threadID ?: -1, message.sentTimestamp!!)
|
||||
} else {
|
||||
|
@ -3,13 +3,12 @@ package org.session.libsession.messaging.messages.visible
|
||||
import android.util.Size
|
||||
import android.webkit.MimeTypeMap
|
||||
import com.google.protobuf.ByteString
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment as SignalAttachment
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.PointerAttachment
|
||||
import org.session.libsignal.libsignal.util.guava.Optional
|
||||
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import java.io.File
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment as SignalAttachment
|
||||
|
||||
class Attachment {
|
||||
|
||||
@ -101,9 +100,7 @@ class Attachment {
|
||||
|
||||
fun toSignalAttachment(): SignalAttachment? {
|
||||
if (!isValid()) return null
|
||||
return DatabaseAttachment(null, 0, false, false, contentType, 0,
|
||||
sizeInBytes?.toLong() ?: 0, if (fileName.isNullOrEmpty()) null else fileName, null, Base64.encodeBytes(key), null, digest, null, kind == Kind.VOICE_MESSAGE,
|
||||
size?.width ?: 0, size?.height ?: 0, false, caption, url)
|
||||
return PointerAttachment.forAttachment((this))
|
||||
}
|
||||
|
||||
fun toSignalPointer(): SignalServiceAttachmentPointer? {
|
||||
|
@ -169,4 +169,25 @@ public class PointerAttachment extends Attachment {
|
||||
thumbnail != null ? thumbnail.asPointer().getCaption().orNull() : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getUrl() : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Session Attachment to a Signal Attachment
|
||||
* @param attachment Session Attachment
|
||||
* @return Signal Attachment
|
||||
*/
|
||||
public static Attachment forAttachment(org.session.libsession.messaging.messages.visible.Attachment attachment) {
|
||||
return new PointerAttachment(attachment.getContentType(),
|
||||
AttachmentTransferProgress.TRANSFER_PROGRESS_PENDING,
|
||||
attachment.getSizeInBytes(),
|
||||
attachment.getFileName(),
|
||||
null, Base64.encodeBytes(attachment.getKey()),
|
||||
null,
|
||||
attachment.getDigest(),
|
||||
null,
|
||||
attachment.getKind() == org.session.libsession.messaging.messages.visible.Attachment.Kind.VOICE_MESSAGE,
|
||||
attachment.getSize() != null ? attachment.getSize().getWidth() : 0,
|
||||
attachment.getSize() != null ? attachment.getSize().getHeight() : 0,
|
||||
attachment.getCaption(),
|
||||
attachment.getUrl());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user