mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
Make received message hash values cache user specific
This commit is contained in:
parent
d1e4577132
commit
ab99db6059
@ -9,7 +9,7 @@ import org.whispersystems.signalservice.loki.api.LokiAPIDatabaseProtocol
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPITarget
|
||||
import org.whispersystems.signalservice.loki.api.LokiSwarmAPI
|
||||
|
||||
class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiAPIDatabaseProtocol {
|
||||
class LokiAPIDatabase(private val userPublicKey: String, context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiAPIDatabaseProtocol {
|
||||
|
||||
companion object {
|
||||
// Swarm cache
|
||||
@ -54,7 +54,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
}
|
||||
|
||||
override fun getReceivedMessageHashValues(): Set<String>? {
|
||||
return get(receivedMessageHashValuesCache, "$userID = ?", wrap("0")) { cursor ->
|
||||
return get(receivedMessageHashValuesCache, "$userID = ?", wrap(userPublicKey)) { cursor ->
|
||||
val receivedMessageHashValuesAsString = cursor.getString(cursor.getColumnIndexOrThrow(receivedMessageHashValues))
|
||||
receivedMessageHashValuesAsString.split(",").toSet()
|
||||
}
|
||||
@ -63,7 +63,7 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
||||
override fun setReceivedMessageHashValues(newValue: Set<String>) {
|
||||
val database = databaseHelper.writableDatabase
|
||||
val receivedMessageHashValuesAsString = newValue.joinToString(",")
|
||||
database.update(receivedMessageHashValuesCache, wrap(mapOf( receivedMessageHashValues to receivedMessageHashValuesAsString )), "$userID = ?", wrap("0"))
|
||||
database.update(receivedMessageHashValuesCache, wrap(mapOf( receivedMessageHashValues to receivedMessageHashValuesAsString )), "$userID = ?", wrap(userPublicKey))
|
||||
}
|
||||
|
||||
// region Convenience
|
||||
|
Loading…
Reference in New Issue
Block a user