This commit is contained in:
Ryan ZHAO 2020-12-10 15:31:14 +11:00
parent ce4f7a6eff
commit c3552bfded
5 changed files with 9 additions and 26 deletions

View File

@ -1,8 +1,6 @@
package org.session.libsession.messaging.messages.visible
import android.content.Context
import org.session.libsession.database.MessageDataProvider
import org.session.libsession.messaging.Configuration
import org.session.libsession.messaging.MessagingConfiguration
import org.session.libsignal.libsignal.logging.Log
import org.session.libsignal.service.internal.push.SignalServiceProtos
@ -46,7 +44,7 @@ class LinkPreview() {
title?.let { linkPreviewProto.title = title }
val attachmentID = attachmentID
attachmentID?.let {
val attachmentProto = Configuration.shared.messageDataProvider.getAttachment(attachmentID)
val attachmentProto = MessagingConfiguration.shared.messageDataProvider.getAttachment(attachmentID)
attachmentProto?.let { linkPreviewProto.image = attachmentProto.toProto() }
}
// Build

View File

@ -2,7 +2,7 @@ package org.session.libsession.messaging.messages.visible
import com.goterl.lazycode.lazysodium.BuildConfig
import org.session.libsession.database.MessageDataProvider
import org.session.libsession.messaging.Configuration
import org.session.libsession.messaging.MessagingConfiguration
import org.session.libsignal.libsignal.logging.Log
import org.session.libsignal.service.internal.push.SignalServiceProtos
@ -48,7 +48,7 @@ class Quote() {
quoteProto.id = timestamp
quoteProto.author = publicKey
text?.let { quoteProto.text = text }
addAttachmentsIfNeeded(quoteProto, Configuration.shared.messageDataProvider)
addAttachmentsIfNeeded(quoteProto, MessagingConfiguration.shared.messageDataProvider)
// Build
try {
return quoteProto.build()

View File

@ -2,8 +2,7 @@ package org.session.libsession.messaging.messages.visible
import com.goterl.lazycode.lazysodium.BuildConfig
import org.session.libsession.database.MessageDataProvider
import org.session.libsession.messaging.Configuration
import org.session.libsession.messaging.MessagingConfiguration
import org.session.libsession.messaging.messages.Message
import org.session.libsignal.libsignal.logging.Log
@ -52,7 +51,7 @@ class VisibleMessage : Message() {
return false
}
fun toProto(): SignalServiceProtos.Content? {
override fun toProto(): SignalServiceProtos.Content? {
val proto = SignalServiceProtos.Content.newBuilder()
var attachmentIDs = this.attachmentIDs
val dataMessage: SignalServiceProtos.DataMessage.Builder
@ -91,7 +90,7 @@ class VisibleMessage : Message() {
}
}
//Attachments
val attachments = attachmentIDs.mapNotNull { Configuration.shared.messageDataProvider.getAttachment(it) }
val attachments = attachmentIDs.mapNotNull { MessagingConfiguration.shared.messageDataProvider.getAttachment(it) }
if (!attachments.all { it.isUploaded }) {
if (BuildConfig.DEBUG) {
//TODO equivalent to iOS's preconditionFailure

View File

@ -1,6 +1,6 @@
package org.session.libsession.messaging.opengroups
import org.session.libsession.messaging.Configuration
import org.session.libsession.messaging.MessagingConfiguration
import org.session.libsession.messaging.messages.visible.VisibleMessage
import org.session.libsignal.libsignal.logging.Log
import org.session.libsignal.service.internal.util.Hex
@ -24,7 +24,7 @@ public data class OpenGroupMessage(
// region Settings
companion object {
fun from(message: VisibleMessage, server: String): OpenGroupMessage? {
val storage = Configuration.shared.storage
val storage = MessagingConfiguration.shared.storage
val userPublicKey = storage.getUserPublicKey() ?: return null
// Validation
if (!message.isValid()) { return null } // Should be valid at this point

View File

@ -1,14 +0,0 @@
package org.session.libsession.snode
import org.session.libsignal.service.loki.utilities.Broadcaster
class Configuration(val storage: SnodeStorageProtocol, val broadcaster: Broadcaster) {
companion object {
lateinit var shared: Configuration
fun configure(storage: SnodeStorageProtocol, broadcaster: Broadcaster) {
if (Companion::shared.isInitialized) { return }
shared = Configuration(storage, broadcaster)
}
}
}