Fix IllegalStateException in UpdateTrustWorker
Also split into 2 methods
This commit is contained in:
parent
e89e0724a0
commit
616d3c1988
@ -97,22 +97,17 @@ internal class UpdateTrustWorker(context: Context,
|
|||||||
// Unfortunately we don't have much info on what did exactly changed (is it the cross signing keys of that user,
|
// Unfortunately we don't have much info on what did exactly changed (is it the cross signing keys of that user,
|
||||||
// or a new device?) So we check all again :/
|
// or a new device?) So we check all again :/
|
||||||
Timber.d("## CrossSigning - Updating trust for users: ${userList.logLimit()}")
|
Timber.d("## CrossSigning - Updating trust for users: ${userList.logLimit()}")
|
||||||
|
updateTrust(userList)
|
||||||
Realm.getInstance(cryptoRealmConfiguration).use { cryptoRealm ->
|
|
||||||
Realm.getInstance(sessionRealmConfiguration).use {
|
|
||||||
updateTrust(userList, cryptoRealm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup(params)
|
cleanup(params)
|
||||||
return Result.success()
|
return Result.success()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun updateTrust(userListParam: List<String>,
|
private suspend fun updateTrust(userListParam: List<String>) {
|
||||||
cRealm: Realm) {
|
|
||||||
var userList = userListParam
|
var userList = userListParam
|
||||||
var myCrossSigningInfo: MXCrossSigningInfo? = null
|
var myCrossSigningInfo: MXCrossSigningInfo? = null
|
||||||
|
|
||||||
// First we check that the users MSK are trusted by mine
|
// First we check that the users MSK are trusted by mine
|
||||||
// After that we check the trust chain for each devices of each users
|
// After that we check the trust chain for each devices of each users
|
||||||
awaitTransaction(cryptoRealmConfiguration) { cryptoRealm ->
|
awaitTransaction(cryptoRealmConfiguration) { cryptoRealm ->
|
||||||
@ -203,9 +198,13 @@ internal class UpdateTrustWorker(context: Context,
|
|||||||
|
|
||||||
// So Cross Signing keys trust is updated, device trust is updated
|
// So Cross Signing keys trust is updated, device trust is updated
|
||||||
// We can now update room shields? in the session DB?
|
// We can now update room shields? in the session DB?
|
||||||
|
updateTrustStep2(userList, myCrossSigningInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun updateTrustStep2(userList: List<String>, myCrossSigningInfo: MXCrossSigningInfo?) {
|
||||||
Timber.d("## CrossSigning - Updating shields for impacted rooms...")
|
Timber.d("## CrossSigning - Updating shields for impacted rooms...")
|
||||||
awaitTransaction(sessionRealmConfiguration) { sessionRealm ->
|
awaitTransaction(sessionRealmConfiguration) { sessionRealm ->
|
||||||
|
Realm.getInstance(cryptoRealmConfiguration).use { cryptoRealm ->
|
||||||
sessionRealm.where(RoomMemberSummaryEntity::class.java)
|
sessionRealm.where(RoomMemberSummaryEntity::class.java)
|
||||||
.`in`(RoomMemberSummaryEntityFields.USER_ID, userList.toTypedArray())
|
.`in`(RoomMemberSummaryEntityFields.USER_ID, userList.toTypedArray())
|
||||||
.distinct(RoomMemberSummaryEntityFields.ROOM_ID)
|
.distinct(RoomMemberSummaryEntityFields.ROOM_ID)
|
||||||
@ -222,7 +221,7 @@ internal class UpdateTrustWorker(context: Context,
|
|||||||
try {
|
try {
|
||||||
val updatedTrust = computeRoomShield(
|
val updatedTrust = computeRoomShield(
|
||||||
myCrossSigningInfo,
|
myCrossSigningInfo,
|
||||||
cRealm,
|
cryptoRealm,
|
||||||
allActiveRoomMembers,
|
allActiveRoomMembers,
|
||||||
roomSummary
|
roomSummary
|
||||||
)
|
)
|
||||||
@ -237,6 +236,7 @@ internal class UpdateTrustWorker(context: Context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getCrossSigningInfo(cryptoRealm: Realm, userId: String): MXCrossSigningInfo? {
|
private fun getCrossSigningInfo(cryptoRealm: Realm, userId: String): MXCrossSigningInfo? {
|
||||||
return cryptoRealm.where(CrossSigningInfoEntity::class.java)
|
return cryptoRealm.where(CrossSigningInfoEntity::class.java)
|
||||||
|
Loading…
Reference in New Issue
Block a user