mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-11-04 01:01:22 +00:00 
			
		
		
		
	move messageDataProvider to configuration
This commit is contained in:
		@@ -1,22 +1,31 @@
 | 
			
		||||
package org.session.libsession.messaging
 | 
			
		||||
 | 
			
		||||
import org.session.libsession.database.MessageDataProvider
 | 
			
		||||
import org.session.libsignal.libsignal.loki.SessionResetProtocol
 | 
			
		||||
import org.session.libsignal.libsignal.state.*
 | 
			
		||||
import org.session.libsignal.metadata.certificate.CertificateValidator
 | 
			
		||||
import org.session.libsignal.service.loki.protocol.closedgroups.SharedSenderKeysDatabaseProtocol
 | 
			
		||||
 | 
			
		||||
class Configuration(val storage: StorageProtocol, val signalStorage: SignalProtocolStore, val sskDatabase: SharedSenderKeysDatabaseProtocol, val sessionResetImp: SessionResetProtocol, val certificateValidator: CertificateValidator) {
 | 
			
		||||
class Configuration(
 | 
			
		||||
        val storage: StorageProtocol,
 | 
			
		||||
        val signalStorage: SignalProtocolStore,
 | 
			
		||||
        val sskDatabase: SharedSenderKeysDatabaseProtocol,
 | 
			
		||||
        val messageDataProvider: MessageDataProvider,
 | 
			
		||||
        val sessionResetImp: SessionResetProtocol,
 | 
			
		||||
        val certificateValidator: CertificateValidator)
 | 
			
		||||
{
 | 
			
		||||
    companion object {
 | 
			
		||||
        lateinit var shared: Configuration
 | 
			
		||||
 | 
			
		||||
        fun configure(storage: StorageProtocol,
 | 
			
		||||
                      signalStorage: SignalProtocolStore,
 | 
			
		||||
                      sskDatabase: SharedSenderKeysDatabaseProtocol,
 | 
			
		||||
                      messageDataProvider: MessageDataProvider,
 | 
			
		||||
                      sessionResetImp: SessionResetProtocol,
 | 
			
		||||
                      certificateValidator: CertificateValidator
 | 
			
		||||
        ) {
 | 
			
		||||
            if (Companion::shared.isInitialized) { return }
 | 
			
		||||
            shared = Configuration(storage, signalStorage, sskDatabase, sessionResetImp, certificateValidator)
 | 
			
		||||
            shared = Configuration(storage, signalStorage, sskDatabase, messageDataProvider, sessionResetImp, certificateValidator)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,6 +2,7 @@ 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.libsignal.libsignal.logging.Log
 | 
			
		||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
 | 
			
		||||
 | 
			
		||||
@@ -45,7 +46,7 @@ class LinkPreview() {
 | 
			
		||||
        title?.let { linkPreviewProto.title = title }
 | 
			
		||||
        val attachmentID = attachmentID
 | 
			
		||||
        attachmentID?.let {
 | 
			
		||||
            val attachmentProto = messageDataProvider.getAttachment(attachmentID)
 | 
			
		||||
            val attachmentProto = Configuration.shared.messageDataProvider.getAttachment(attachmentID)
 | 
			
		||||
            attachmentProto?.let { linkPreviewProto.image = attachmentProto.toProto() }
 | 
			
		||||
        }
 | 
			
		||||
        // Build
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +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.libsignal.libsignal.logging.Log
 | 
			
		||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
 | 
			
		||||
 | 
			
		||||
@@ -47,7 +48,7 @@ class Quote() {
 | 
			
		||||
        quoteProto.id = timestamp
 | 
			
		||||
        quoteProto.author = publicKey
 | 
			
		||||
        text?.let { quoteProto.text = text }
 | 
			
		||||
        addAttachmentsIfNeeded(quoteProto, messageDataProvider)
 | 
			
		||||
        addAttachmentsIfNeeded(quoteProto, Configuration.shared.messageDataProvider)
 | 
			
		||||
        // Build
 | 
			
		||||
        try {
 | 
			
		||||
            return quoteProto.build()
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,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.messages.Message
 | 
			
		||||
 | 
			
		||||
import org.session.libsignal.libsignal.logging.Log
 | 
			
		||||
@@ -90,7 +91,7 @@ class VisibleMessage : Message()  {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //Attachments
 | 
			
		||||
        val attachments = attachmentIDs.mapNotNull { messageDataProvider.getAttachment(it) }
 | 
			
		||||
        val attachments = attachmentIDs.mapNotNull { Configuration.shared.messageDataProvider.getAttachment(it) }
 | 
			
		||||
        if (!attachments.all { it.isUploaded }) {
 | 
			
		||||
            if (BuildConfig.DEBUG) {
 | 
			
		||||
                //TODO equivalent to iOS's preconditionFailure
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user