|
|
@ -1,13 +1,10 @@
|
|
|
|
package org.session.libsession.messaging.messages.visible
|
|
|
|
package org.session.libsession.messaging.messages.visible
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.protobuf.ByteString
|
|
|
|
|
|
|
|
import com.goterl.lazycode.lazysodium.BuildConfig
|
|
|
|
import com.goterl.lazycode.lazysodium.BuildConfig
|
|
|
|
import org.session.libsession.messaging.MessagingConfiguration
|
|
|
|
import org.session.libsession.messaging.MessagingConfiguration
|
|
|
|
import org.session.libsession.messaging.messages.Message
|
|
|
|
import org.session.libsession.messaging.messages.Message
|
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
|
|
|
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer
|
|
|
|
|
|
|
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|
|
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
|
|
|
import org.session.libsignal.service.internal.push.SignalServiceProtos.AttachmentPointer
|
|
|
|
|
|
|
|
import org.session.libsignal.utilities.logging.Log
|
|
|
|
import org.session.libsignal.utilities.logging.Log
|
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment as SignalAttachment
|
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.Attachment as SignalAttachment
|
|
|
|
|
|
|
|
|
|
|
@ -72,7 +69,7 @@ class VisibleMessage : Message() {
|
|
|
|
|
|
|
|
|
|
|
|
override fun toProto(): SignalServiceProtos.Content? {
|
|
|
|
override fun toProto(): SignalServiceProtos.Content? {
|
|
|
|
val proto = SignalServiceProtos.Content.newBuilder()
|
|
|
|
val proto = SignalServiceProtos.Content.newBuilder()
|
|
|
|
var attachmentIDs = this.attachmentIDs
|
|
|
|
val attachmentIDs = this.attachmentIDs
|
|
|
|
val dataMessage: SignalServiceProtos.DataMessage.Builder
|
|
|
|
val dataMessage: SignalServiceProtos.DataMessage.Builder
|
|
|
|
// Profile
|
|
|
|
// Profile
|
|
|
|
val profile = profile
|
|
|
|
val profile = profile
|
|
|
@ -116,7 +113,7 @@ class VisibleMessage : Message() {
|
|
|
|
Log.d(TAG, "Sending a message before all associated attachments have been uploaded.")
|
|
|
|
Log.d(TAG, "Sending a message before all associated attachments have been uploaded.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val attachmentPointers = attachments.mapNotNull { createAttachmentPointer(it) }
|
|
|
|
val attachmentPointers = attachments.mapNotNull { Attachment.createAttachmentPointer(it) }
|
|
|
|
dataMessage.addAllAttachments(attachmentPointers)
|
|
|
|
dataMessage.addAllAttachments(attachmentPointers)
|
|
|
|
// Sync target
|
|
|
|
// Sync target
|
|
|
|
if (syncTarget != null) {
|
|
|
|
if (syncTarget != null) {
|
|
|
@ -132,33 +129,4 @@ class VisibleMessage : Message() {
|
|
|
|
return null
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun createAttachmentPointer(attachment: SignalServiceAttachmentPointer): AttachmentPointer? {
|
|
|
|
|
|
|
|
val builder = AttachmentPointer.newBuilder()
|
|
|
|
|
|
|
|
.setContentType(attachment.contentType)
|
|
|
|
|
|
|
|
.setId(attachment.id)
|
|
|
|
|
|
|
|
.setKey(ByteString.copyFrom(attachment.key))
|
|
|
|
|
|
|
|
.setDigest(ByteString.copyFrom(attachment.digest.get()))
|
|
|
|
|
|
|
|
.setSize(attachment.size.get())
|
|
|
|
|
|
|
|
.setUrl(attachment.url)
|
|
|
|
|
|
|
|
if (attachment.fileName.isPresent) {
|
|
|
|
|
|
|
|
builder.fileName = attachment.fileName.get()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment.preview.isPresent) {
|
|
|
|
|
|
|
|
builder.thumbnail = ByteString.copyFrom(attachment.preview.get())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment.width > 0) {
|
|
|
|
|
|
|
|
builder.width = attachment.width
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment.height > 0) {
|
|
|
|
|
|
|
|
builder.height = attachment.height
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment.voiceNote) {
|
|
|
|
|
|
|
|
builder.flags = AttachmentPointer.Flags.VOICE_MESSAGE_VALUE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment.caption.isPresent) {
|
|
|
|
|
|
|
|
builder.caption = attachment.caption.get()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return builder.build()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|