Use in memory cache when adding inBoundGroupSession
This commit is contained in:
parent
60004f02c3
commit
7142cd899b
1
changelog.d/4011.bugfix
Normal file
1
changelog.d/4011.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Messages are displayed as unable to decrypt then decrypted a few seconds later #4011
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
|
|||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
|
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
|
import org.matrix.android.sdk.internal.session.SessionScope
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
@ -71,18 +72,24 @@ internal class InboundGroupSessionStore @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun storeInBoundGroupSession(wrapper: OlmInboundGroupSessionWrapper2) {
|
fun storeInBoundGroupSession(wrapper: OlmInboundGroupSessionWrapper2, sessionId: String, senderKey: String) {
|
||||||
Timber.v("## Inbound: getInboundGroupSession mark as dirty ${wrapper.roomId}-${wrapper.senderKey}")
|
Timber.v("## Inbound: getInboundGroupSession mark as dirty ${wrapper.roomId}-${wrapper.senderKey}")
|
||||||
// We want to batch this a bit for performances
|
// We want to batch this a bit for performances
|
||||||
dirtySession.add(wrapper)
|
dirtySession.add(wrapper)
|
||||||
|
|
||||||
|
if (sessionCache[CacheKey(sessionId, senderKey)] == null) {
|
||||||
|
// first time seen, put it in memory cache while waiting for batch insert
|
||||||
|
// If it's already known, no need to update cache it's already there
|
||||||
|
sessionCache.put(CacheKey(sessionId, senderKey), wrapper)
|
||||||
|
}
|
||||||
|
|
||||||
timerTask?.cancel()
|
timerTask?.cancel()
|
||||||
timerTask = object : TimerTask() {
|
timerTask = object : TimerTask() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
batchSave()
|
batchSave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timer.schedule(timerTask!!, 2_000)
|
timer.schedule(timerTask!!, 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -577,7 +577,9 @@ internal class MXOlmDevice @Inject constructor(
|
|||||||
session.keysClaimed = keysClaimed
|
session.keysClaimed = keysClaimed
|
||||||
session.forwardingCurve25519KeyChain = forwardingCurve25519KeyChain
|
session.forwardingCurve25519KeyChain = forwardingCurve25519KeyChain
|
||||||
|
|
||||||
store.storeInboundGroupSessions(listOf(session))
|
|
||||||
|
inboundGroupSessionStore.storeInBoundGroupSession(session, sessionId, senderKey)
|
||||||
|
// store.storeInboundGroupSessions(listOf(session))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -703,7 +705,7 @@ internal class MXOlmDevice @Inject constructor(
|
|||||||
timelineSet.add(messageIndexKey)
|
timelineSet.add(messageIndexKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
inboundGroupSessionStore.storeInBoundGroupSession(session)
|
inboundGroupSessionStore.storeInBoundGroupSession(session, sessionId, senderKey)
|
||||||
val payload = try {
|
val payload = try {
|
||||||
val adapter = MoshiProvider.providesMoshi().adapter<JsonDict>(JSON_DICT_PARAMETERIZED_TYPE)
|
val adapter = MoshiProvider.providesMoshi().adapter<JsonDict>(JSON_DICT_PARAMETERIZED_TYPE)
|
||||||
val payloadString = convertFromUTF8(decryptResult.mDecryptedMessage)
|
val payloadString = convertFromUTF8(decryptResult.mDecryptedMessage)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user