mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-25 20:07:21 +00:00
commit
299d81f4dc
@ -66,9 +66,13 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
val database = databaseHelper.readableDatabase
|
val database = databaseHelper.readableDatabase
|
||||||
return database.get(swarmCache, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey)) { cursor ->
|
return database.get(swarmCache, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey)) { cursor ->
|
||||||
val swarmAsString = cursor.getString(cursor.getColumnIndexOrThrow(swarm))
|
val swarmAsString = cursor.getString(cursor.getColumnIndexOrThrow(swarm))
|
||||||
swarmAsString.split(", ").map { targetAsString ->
|
swarmAsString.split(", ").mapNotNull { targetAsString ->
|
||||||
val components = targetAsString.split("?port=")
|
val components = targetAsString.split("-")
|
||||||
LokiAPITarget(components[0], components[1].toInt())
|
val address = components[0]
|
||||||
|
val port = components.getOrNull(1)?.toIntOrNull() ?: return@mapNotNull null
|
||||||
|
val idKey = components.getOrNull(2) ?: return@mapNotNull null
|
||||||
|
val encryptionKey = components.getOrNull(3)?: return@mapNotNull null
|
||||||
|
LokiAPITarget(address, port, LokiAPITarget.KeySet(idKey, encryptionKey))
|
||||||
}
|
}
|
||||||
}?.toSet()
|
}?.toSet()
|
||||||
}
|
}
|
||||||
@ -76,7 +80,12 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
override fun setSwarmCache(hexEncodedPublicKey: String, newValue: Set<LokiAPITarget>) {
|
override fun setSwarmCache(hexEncodedPublicKey: String, newValue: Set<LokiAPITarget>) {
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
val swarmAsString = newValue.joinToString(", ") { target ->
|
val swarmAsString = newValue.joinToString(", ") { target ->
|
||||||
"${target.address}?port=${target.port}"
|
var string = "${target.address}-${target.port}"
|
||||||
|
val keySet = target.publicKeySet
|
||||||
|
if (keySet != null) {
|
||||||
|
string += "-${keySet.idKey}-${keySet.encryptionKey}"
|
||||||
|
}
|
||||||
|
string
|
||||||
}
|
}
|
||||||
val row = wrap(mapOf( Companion.hexEncodedPublicKey to hexEncodedPublicKey, swarm to swarmAsString ))
|
val row = wrap(mapOf( Companion.hexEncodedPublicKey to hexEncodedPublicKey, swarm to swarmAsString ))
|
||||||
database.insertOrUpdate(swarmCache, row, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey))
|
database.insertOrUpdate(swarmCache, row, "${Companion.hexEncodedPublicKey} = ?", wrap(hexEncodedPublicKey))
|
||||||
|
@ -129,6 +129,7 @@ class RegisterActivity : BaseActionBarActivity() {
|
|||||||
IdentityKeyUtil.getIdentityKeyPair(this).publicKey, IdentityDatabase.VerifiedStatus.VERIFIED,
|
IdentityKeyUtil.getIdentityKeyPair(this).publicKey, IdentityDatabase.VerifiedStatus.VERIFIED,
|
||||||
true, System.currentTimeMillis(), true)
|
true, System.currentTimeMillis(), true)
|
||||||
TextSecurePreferences.setLocalNumber(this, userHexEncodedPublicKey)
|
TextSecurePreferences.setLocalNumber(this, userHexEncodedPublicKey)
|
||||||
|
TextSecurePreferences.setHasViewedSeed(this, false)
|
||||||
val intent = Intent(this, DisplayNameActivity::class.java)
|
val intent = Intent(this, DisplayNameActivity::class.java)
|
||||||
push(intent)
|
push(intent)
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ class RestoreActivity : BaseActionBarActivity() {
|
|||||||
IdentityKeyUtil.getIdentityKeyPair(this).publicKey, IdentityDatabase.VerifiedStatus.VERIFIED,
|
IdentityKeyUtil.getIdentityKeyPair(this).publicKey, IdentityDatabase.VerifiedStatus.VERIFIED,
|
||||||
true, System.currentTimeMillis(), true)
|
true, System.currentTimeMillis(), true)
|
||||||
TextSecurePreferences.setLocalNumber(this, userHexEncodedPublicKey)
|
TextSecurePreferences.setLocalNumber(this, userHexEncodedPublicKey)
|
||||||
|
TextSecurePreferences.setHasViewedSeed(this, true)
|
||||||
val intent = Intent(this, DisplayNameActivity::class.java)
|
val intent = Intent(this, DisplayNameActivity::class.java)
|
||||||
push(intent)
|
push(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user