mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 09:12:19 +00:00
Pass PreKeyBundleStore into message sender.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user