Pass PreKeyBundleStore into message sender.

This commit is contained in:
Mikunj
2019-06-05 09:29:18 +10:00
parent 4148d598f9
commit a0f95c033a
4 changed files with 40 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.libsignal.IdentityKey
import org.whispersystems.libsignal.ecc.Curve
import org.whispersystems.libsignal.state.PreKeyBundle
import org.whispersystems.signalservice.api.push.SignalServiceAddress
class LokiPreKeyBundleDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
@@ -57,9 +58,7 @@ class LokiPreKeyBundleDatabase(context: Context, helper: SQLCipherOpenHelper) :
val registrationId = TextSecurePreferences.getLocalRegistrationId(context)
if (registrationId == 0) return null
// TODO: This is the primary device id, we may want to change it to support multiple devices?
val deviceId = 1
val deviceId = SignalServiceAddress.DEFAULT_DEVICE_ID
return PreKeyBundle(registrationId, deviceId,preKeyRecord.id, preKeyRecord.keyPair.publicKey, signedPreKey.id, signedPreKey.keyPair.publicKey, signedPreKey.signature, identityKeyPair.publicKey)
}

View File

@@ -0,0 +1,24 @@
package org.thoughtcrime.securesms.loki
import android.content.Context
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.whispersystems.libsignal.state.PreKeyBundle
import org.whispersystems.signalservice.loki.utilities.LokiPreKeyBundleStore
class LokiPreKeyBundleStoreImpl(val context: Context): LokiPreKeyBundleStore {
companion object {
val FILE_LOCK = Object()
}
override fun getPreKeyBundle(pubKey: String): PreKeyBundle? {
synchronized (FILE_LOCK) {
return DatabaseFactory.getLokiPreKeyBundleDatabase(context).getPreKeyBundle(pubKey)
}
}
override fun removePreKeyBundle(pubKey: String) {
synchronized (FILE_LOCK) {
DatabaseFactory.getLokiPreKeyBundleDatabase(context).removePreKeyBundle(pubKey)
}
}
}