Create a new `fun` for code clarity

This commit is contained in:
Benoit Marty 2022-08-29 14:27:26 +02:00
parent f668be5266
commit a8eb7d95ac
4 changed files with 12 additions and 7 deletions

View File

@ -779,6 +779,11 @@ internal class DefaultCrossSigningService @Inject constructor(
override fun onUsersDeviceUpdate(userIds: List<String>) {
Timber.d("## CrossSigning - onUsersDeviceUpdate for users: ${userIds.logLimit()}")
checkTrustAndAffectedRoomShields(userIds)
}
fun checkTrustAndAffectedRoomShields(userIds: List<String>) {
Timber.d("## CrossSigning - checkTrustAndAffectedRoomShields for users: ${userIds.logLimit()}")
val workerParams = UpdateTrustWorker.Params(
sessionId = sessionId,
filename = updateTrustWorkerDataRepository.createParam(userIds)

View File

@ -185,10 +185,10 @@ internal class RoomSummaryUpdater @Inject constructor(
if (aggregator == null) {
// Do it now
// mmm maybe we could only refresh shield instead of checking trust also?
crossSigningService.onUsersDeviceUpdate(otherRoomMembers)
crossSigningService.checkTrustAndAffectedRoomShields(otherRoomMembers)
} else {
// Schedule it
aggregator.userIdsWithDeviceUpdate.addAll(otherRoomMembers)
aggregator.userIdsForCheckingTrustAndAffectedRoomShields.addAll(otherRoomMembers)
}
}
}

View File

@ -26,6 +26,6 @@ internal class SyncResponsePostTreatmentAggregator {
// Set of userIds to fetch and update at the end of incremental syncs
val userIdsToFetch = mutableSetOf<String>()
// Set of users to call `crossSigningService.onUsersDeviceUpdate` once per sync
val userIdsWithDeviceUpdate = mutableSetOf<String>()
// Set of users to call `crossSigningService.checkTrustAndAffectedRoomShields` once per sync
val userIdsForCheckingTrustAndAffectedRoomShields = mutableSetOf<String>()
}

View File

@ -48,7 +48,7 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
cleanupEphemeralFiles(aggregator.ephemeralFilesToDelete)
updateDirectUserIds(aggregator.directChatsToCheck)
fetchAndUpdateUsers(aggregator.userIdsToFetch)
handleUserIdsWithDeviceUpdate(aggregator.userIdsWithDeviceUpdate)
handleUserIdsForCheckingTrustAndAffectedRoomShields(aggregator.userIdsForCheckingTrustAndAffectedRoomShields)
}
private fun cleanupEphemeralFiles(ephemeralFilesToDelete: List<String>) {
@ -105,7 +105,7 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
.enqueue()
}
private fun handleUserIdsWithDeviceUpdate(userIdsWithDeviceUpdate: Iterable<String>) {
crossSigningService.onUsersDeviceUpdate(userIdsWithDeviceUpdate.toList())
private fun handleUserIdsForCheckingTrustAndAffectedRoomShields(userIdsWithDeviceUpdate: Iterable<String>) {
crossSigningService.checkTrustAndAffectedRoomShields(userIdsWithDeviceUpdate.toList())
}
}