Fix received message hash values storage

This commit is contained in:
nielsandriesse 2020-08-20 09:19:00 +10:00
parent a4c6b39ffa
commit af1f45a6e4

View File

@ -215,9 +215,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
override fun getReceivedMessageHashValues(publicKey: String): Set<String>? {
val database = databaseHelper.readableDatabase
val query = "$Companion.publicKey = ?"
val query = "${Companion.publicKey} = ?"
return database.get(receivedMessageHashValuesTable2, query, arrayOf( publicKey )) { cursor ->
val receivedMessageHashValuesAsString = cursor.getString(cursor.getColumnIndexOrThrow(receivedMessageHashValues))
val receivedMessageHashValuesAsString = cursor.getString(cursor.getColumnIndexOrThrow(Companion.receivedMessageHashValues))
receivedMessageHashValuesAsString.split("-").toSet()
}
}
@ -225,8 +225,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
override fun setReceivedMessageHashValues(publicKey: String, newValue: Set<String>) {
val database = databaseHelper.writableDatabase
val receivedMessageHashValuesAsString = newValue.joinToString("-")
val row = wrap(mapOf( Companion.publicKey to publicKey, receivedMessageHashValues to receivedMessageHashValuesAsString ))
val query = "$Companion.publicKey = ?"
val row = wrap(mapOf( Companion.publicKey to publicKey, Companion.receivedMessageHashValues to receivedMessageHashValuesAsString ))
val query = "${Companion.publicKey} = ?"
database.insertOrUpdate(receivedMessageHashValuesTable2, row, query, arrayOf( publicKey ))
}