mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Debug
This commit is contained in:
parent
6c5034f4b3
commit
96f235423d
@ -59,7 +59,7 @@ class ClosedGroupPoller private constructor(private val context: Context, privat
|
||||
// region Private API
|
||||
private fun poll() {
|
||||
if (!isPolling) { return }
|
||||
val publicKeys = database.getAllClosedGroupPublicKeys().map { "05$it" }
|
||||
val publicKeys = database.getAllClosedGroupPublicKeys()
|
||||
publicKeys.forEach { publicKey ->
|
||||
SwarmAPI.shared.getSwarm(publicKey).bind { swarm ->
|
||||
val snode = swarm.getRandomElementOrNull() ?: throw InsufficientSnodesException() // Should be cryptographically secure
|
||||
|
@ -36,7 +36,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
private val lastMessageHashValueTable2 = "last_message_hash_value_table"
|
||||
private val lastMessageHashValue = "last_message_hash_value"
|
||||
@JvmStatic val createLastMessageHashValueTable2Command
|
||||
= "CREATE TABLE $lastMessageHashValueTable2 ($snode STRING, $publicKey STRING, $lastMessageHashValue STRING, PRIMARY KEY ($snode, $publicKey));"
|
||||
= "CREATE TABLE $lastMessageHashValueTable2 ($snode STRING, $publicKey STRING, $lastMessageHashValue TEXT, PRIMARY KEY ($snode, $publicKey));"
|
||||
// Received message hash values
|
||||
private val receivedMessageHashValuesTable2 = "received_message_hash_values_table"
|
||||
private val receivedMessageHashValues = "received_message_hash_values"
|
||||
|
@ -101,6 +101,8 @@ class SharedSenderKeysDatabase(context: Context, helper: SQLCipherOpenHelper) :
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.getAll(closedGroupPrivateKeyTable, null, null) { cursor ->
|
||||
cursor.getString(Companion.closedGroupPublicKey)
|
||||
}.filter {
|
||||
PublicKeyValidation.isValid(it)
|
||||
}.toSet()
|
||||
}
|
||||
// endregion
|
||||
|
@ -206,6 +206,10 @@ object ClosedGroupsProtocol {
|
||||
}
|
||||
val members = closedGroupUpdate.membersList.map { it.toByteArray().toHexString() }
|
||||
val admins = closedGroupUpdate.adminsList.map { it.toByteArray().toHexString() }
|
||||
if (groupPublicKey.isEmpty() || name.isEmpty() || groupPrivateKey.isEmpty() || senderKeys.isEmpty() || members.isEmpty() || admins.isEmpty()) {
|
||||
Log.d("Loki", "Ignoring invalid new closed group.")
|
||||
return
|
||||
}
|
||||
// Persist the ratchets
|
||||
senderKeys.forEach { senderKey ->
|
||||
if (!members.contains(senderKey.publicKey.toHexString())) { return@forEach }
|
||||
@ -218,7 +222,7 @@ object ClosedGroupsProtocol {
|
||||
null, null, LinkedList<Address>(admins.map { Address.fromSerialized(it) }))
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(Recipient.from(context, Address.fromSerialized(groupID), false), true)
|
||||
// Add the group to the user's set of public keys to poll for
|
||||
sskDatabase.setClosedGroupPrivateKey(groupPrivateKey.toHexString(), groupPublicKey)
|
||||
sskDatabase.setClosedGroupPrivateKey(groupPublicKey, groupPrivateKey.toHexString())
|
||||
// Notify the user
|
||||
// TODO: Implement
|
||||
// Establish sessions if needed
|
||||
|
Loading…
Reference in New Issue
Block a user