mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
After Ganfra's review
This commit is contained in:
parent
d25cf79b07
commit
8e1a964679
25 changed files with 79 additions and 107 deletions
|
@ -23,8 +23,7 @@ import timber.log.Timber
|
|||
import javax.inject.Inject
|
||||
|
||||
internal class SetDeviceVerificationAction @Inject constructor(private val cryptoStore: IMXCryptoStore,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val keysBackup: KeysBackup) {
|
||||
|
||||
fun handle(verificationStatus: Int, deviceId: String, userId: String) {
|
||||
|
|
|
@ -27,8 +27,7 @@ import im.vector.matrix.android.internal.di.UserId
|
|||
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class MXMegolmDecryptionFactory @Inject constructor(@UserId
|
||||
private val userId: String,
|
||||
internal class MXMegolmDecryptionFactory @Inject constructor(@UserId private val userId: String,
|
||||
private val olmDevice: MXOlmDevice,
|
||||
private val deviceListManager: DeviceListManager,
|
||||
private val outgoingRoomKeyRequestManager: OutgoingRoomKeyRequestManager,
|
||||
|
|
|
@ -21,8 +21,7 @@ import im.vector.matrix.android.internal.di.UserId
|
|||
import javax.inject.Inject
|
||||
|
||||
internal class MXOlmDecryptionFactory @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||
@UserId
|
||||
private val userId: String) {
|
||||
@UserId private val userId: String) {
|
||||
|
||||
fun create(): MXOlmDecryption {
|
||||
return MXOlmDecryption(
|
||||
|
|
|
@ -34,8 +34,7 @@ internal interface DeleteDeviceWithUserPasswordTask : Task<DeleteDeviceWithUserP
|
|||
}
|
||||
|
||||
internal class DefaultDeleteDeviceWithUserPasswordTask @Inject constructor(private val cryptoApi: CryptoApi,
|
||||
@UserId
|
||||
private val userId: String)
|
||||
@UserId private val userId: String)
|
||||
: DeleteDeviceWithUserPasswordTask {
|
||||
|
||||
override suspend fun execute(params: DeleteDeviceWithUserPasswordTask.Params) {
|
||||
|
|
|
@ -40,8 +40,7 @@ import java.io.IOException
|
|||
import javax.inject.Inject
|
||||
|
||||
internal class DefaultFileService @Inject constructor(private val context: Context,
|
||||
@UserMd5
|
||||
private val userMd5: String,
|
||||
@UserMd5 private val userMd5: String,
|
||||
private val contentUrlResolver: ContentUrlResolver,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers) : FileService {
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ internal interface SaveFilterTask : Task<SaveFilterTask.Params, Unit> {
|
|||
|
||||
}
|
||||
|
||||
internal class DefaultSaveFilterTask @Inject constructor(@UserId
|
||||
private val userId: String,
|
||||
internal class DefaultSaveFilterTask @Inject constructor(@UserId private val userId: String,
|
||||
private val filterAPI: FilterApi,
|
||||
private val filterRepository: FilterRepository
|
||||
) : SaveFilterTask {
|
||||
|
|
|
@ -36,8 +36,7 @@ import javax.inject.Inject
|
|||
private const val GET_GROUP_DATA_WORKER = "GET_GROUP_DATA_WORKER"
|
||||
|
||||
internal class GroupSummaryUpdater @Inject constructor(private val context: Context,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val monarchy: Monarchy)
|
||||
: RealmLiveEntityObserver<GroupEntity>(monarchy.realmConfiguration) {
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ internal interface ProcessEventForPushTask : Task<ProcessEventForPushTask.Params
|
|||
internal class DefaultProcessEventForPushTask @Inject constructor(
|
||||
private val defaultPushRuleService: DefaultPushRuleService,
|
||||
private val roomService: RoomService,
|
||||
@UserId
|
||||
private val userId: String
|
||||
@UserId private val userId: String
|
||||
) : ProcessEventForPushTask {
|
||||
|
||||
override suspend fun execute(params: ProcessEventForPushTask.Params) {
|
||||
|
|
|
@ -24,8 +24,7 @@ import timber.log.Timber
|
|||
// TODO Inject constructor
|
||||
internal class DefaultConditionResolver(private val event: Event,
|
||||
private val roomService: RoomService,
|
||||
@UserId
|
||||
private val userId: String) : ConditionResolver {
|
||||
@UserId private val userId: String) : ConditionResolver {
|
||||
|
||||
|
||||
override fun resolveEventMatchCondition(eventMatchCondition: EventMatchCondition): Boolean {
|
||||
|
|
|
@ -39,8 +39,7 @@ import javax.inject.Inject
|
|||
|
||||
internal class DefaultPusherService @Inject constructor(private val context: Context,
|
||||
private val monarchy: Monarchy,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val getPusherTask: GetPushersTask,
|
||||
private val removePusherTask: RemovePusherTask,
|
||||
private val taskExecutor: TaskExecutor
|
||||
|
|
|
@ -38,8 +38,7 @@ import javax.inject.Inject
|
|||
*/
|
||||
|
||||
internal class EventRelationsAggregationUpdater @Inject constructor(@SessionDatabase realmConfiguration: RealmConfiguration,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val task: EventRelationsAggregationTask,
|
||||
private val taskExecutor: TaskExecutor) :
|
||||
RealmLiveEntityObserver<EventEntity>(realmConfiguration) {
|
||||
|
|
|
@ -31,8 +31,7 @@ import im.vector.matrix.android.internal.session.room.membership.RoomMembers
|
|||
import javax.inject.Inject
|
||||
|
||||
internal class RoomAvatarResolver @Inject constructor(private val monarchy: Monarchy,
|
||||
@UserId
|
||||
private val userId: String) {
|
||||
@UserId private val userId: String) {
|
||||
|
||||
/**
|
||||
* Compute the room avatar url
|
||||
|
|
|
@ -39,8 +39,7 @@ import io.realm.Realm
|
|||
import io.realm.kotlin.createObject
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class RoomSummaryUpdater @Inject constructor(@UserId
|
||||
private val userId: String,
|
||||
internal class RoomSummaryUpdater @Inject constructor(@UserId private val userId: String,
|
||||
private val roomDisplayNameResolver: RoomDisplayNameResolver,
|
||||
private val roomAvatarResolver: RoomAvatarResolver,
|
||||
private val monarchy: Monarchy) {
|
||||
|
|
|
@ -37,8 +37,7 @@ import javax.inject.Inject
|
|||
*/
|
||||
internal class RoomDisplayNameResolver @Inject constructor(private val context: Context,
|
||||
private val monarchy: Monarchy,
|
||||
@UserId
|
||||
private val userId: String
|
||||
@UserId private val userId: String
|
||||
) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,8 +37,7 @@ import javax.inject.Inject
|
|||
* As it will actually delete the content, it should be called last in the list of listener.
|
||||
*/
|
||||
internal class EventsPruner @Inject constructor(@SessionDatabase realmConfiguration: RealmConfiguration,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val pruneEventTask: PruneEventTask,
|
||||
private val taskExecutor: TaskExecutor) :
|
||||
RealmLiveEntityObserver<EventEntity>(realmConfiguration) {
|
||||
|
|
|
@ -38,8 +38,7 @@ internal class DefaultReadService @AssistedInject constructor(@Assisted private
|
|||
private val taskExecutor: TaskExecutor,
|
||||
private val setReadMarkersTask: SetReadMarkersTask,
|
||||
private val readReceiptsSummaryMapper: ReadReceiptsSummaryMapper,
|
||||
@UserId
|
||||
private val userId: String
|
||||
@UserId private val userId: String
|
||||
) : ReadService {
|
||||
|
||||
@AssistedInject.Factory
|
||||
|
|
|
@ -48,8 +48,7 @@ private const val READ_MARKER = "m.fully_read"
|
|||
private const val READ_RECEIPT = "m.read"
|
||||
|
||||
internal class DefaultSetReadMarkersTask @Inject constructor(private val roomAPI: RoomAPI,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val monarchy: Monarchy
|
||||
) : SetReadMarkersTask {
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ import timber.log.Timber
|
|||
|
||||
internal class DefaultRelationService @AssistedInject constructor(@Assisted private val roomId: String,
|
||||
private val context: Context,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val eventFactory: LocalEchoEventFactory,
|
||||
private val cryptoService: CryptoService,
|
||||
private val findReactionEventForUndoTask: FindReactionEventForUndoTask,
|
||||
|
|
|
@ -55,8 +55,7 @@ private const val BACKOFF_DELAY = 10_000L
|
|||
|
||||
internal class DefaultSendService @AssistedInject constructor(@Assisted private val roomId: String,
|
||||
private val context: Context,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val localEchoEventFactory: LocalEchoEventFactory,
|
||||
private val cryptoService: CryptoService,
|
||||
private val monarchy: Monarchy
|
||||
|
|
|
@ -50,8 +50,7 @@ import javax.inject.Inject
|
|||
*
|
||||
* The transactionID is used as loc
|
||||
*/
|
||||
internal class LocalEchoEventFactory @Inject constructor(@UserId
|
||||
private val userId: String,
|
||||
internal class LocalEchoEventFactory @Inject constructor(@UserId private val userId: String,
|
||||
private val stringProvider: StringProvider,
|
||||
private val roomSummaryUpdater: RoomSummaryUpdater) {
|
||||
// TODO Inject
|
||||
|
|
|
@ -34,8 +34,7 @@ import javax.inject.Inject
|
|||
internal interface SignOutTask : Task<Unit, Unit>
|
||||
|
||||
internal class DefaultSignOutTask @Inject constructor(private val context: Context,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val signOutAPI: SignOutAPI,
|
||||
private val sessionManager: SessionManager,
|
||||
private val sessionParamsStore: SessionParamsStore,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package im.vector.matrix.android.internal.session.sync
|
||||
|
||||
import arrow.core.Try
|
||||
import im.vector.matrix.android.R
|
||||
import im.vector.matrix.android.internal.crypto.DefaultCryptoService
|
||||
import im.vector.matrix.android.internal.session.DefaultInitialSyncProgressService
|
||||
|
@ -33,73 +32,70 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl
|
|||
private val cryptoService: DefaultCryptoService,
|
||||
private val initialSyncProgressService: DefaultInitialSyncProgressService) {
|
||||
|
||||
suspend fun handleResponse(syncResponse: SyncResponse, fromToken: String?, isCatchingUp: Boolean): Try<SyncResponse> {
|
||||
return Try {
|
||||
val isInitialSync = fromToken == null
|
||||
Timber.v("Start handling sync, is InitialSync: $isInitialSync")
|
||||
val reporter = initialSyncProgressService.takeIf { isInitialSync }
|
||||
suspend fun handleResponse(syncResponse: SyncResponse, fromToken: String?, isCatchingUp: Boolean) {
|
||||
val isInitialSync = fromToken == null
|
||||
Timber.v("Start handling sync, is InitialSync: $isInitialSync")
|
||||
val reporter = initialSyncProgressService.takeIf { isInitialSync }
|
||||
|
||||
measureTimeMillis {
|
||||
if (!cryptoService.isStarted()) {
|
||||
Timber.v("Should start cryptoService")
|
||||
cryptoService.start(isInitialSync)
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling start cryptoService in $it ms")
|
||||
}
|
||||
val measure = measureTimeMillis {
|
||||
// Handle the to device events before the room ones
|
||||
// to ensure to decrypt them properly
|
||||
measureTimeMillis {
|
||||
if (!cryptoService.isStarted()) {
|
||||
Timber.v("Should start cryptoService")
|
||||
cryptoService.start(isInitialSync)
|
||||
Timber.v("Handle toDevice")
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_crypto, 100, 0.1f) {
|
||||
if (syncResponse.toDevice != null) {
|
||||
cryptoSyncHandler.handleToDevice(syncResponse.toDevice, reporter)
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling start cryptoService in $it ms")
|
||||
Timber.v("Finish handling toDevice in $it ms")
|
||||
}
|
||||
val measure = measureTimeMillis {
|
||||
// Handle the to device events before the room ones
|
||||
// to ensure to decrypt them properly
|
||||
measureTimeMillis {
|
||||
Timber.v("Handle toDevice")
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_crypto, 100, 0.1f) {
|
||||
if (syncResponse.toDevice != null) {
|
||||
cryptoSyncHandler.handleToDevice(syncResponse.toDevice, reporter)
|
||||
}
|
||||
|
||||
measureTimeMillis {
|
||||
Timber.v("Handle rooms")
|
||||
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_rooms, 100, 0.7f) {
|
||||
if (syncResponse.rooms != null) {
|
||||
roomSyncHandler.handle(syncResponse.rooms, isInitialSync, reporter)
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling toDevice in $it ms")
|
||||
}
|
||||
|
||||
measureTimeMillis {
|
||||
Timber.v("Handle rooms")
|
||||
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_rooms, 100, 0.7f) {
|
||||
if (syncResponse.rooms != null) {
|
||||
roomSyncHandler.handle(syncResponse.rooms, isInitialSync, reporter)
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling rooms in $it ms")
|
||||
}
|
||||
|
||||
|
||||
measureTimeMillis {
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_groups, 100, 0.1f) {
|
||||
Timber.v("Handle groups")
|
||||
if (syncResponse.groups != null) {
|
||||
groupSyncHandler.handle(syncResponse.groups, reporter)
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling groups in $it ms")
|
||||
}
|
||||
|
||||
measureTimeMillis {
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_data, 100, 0.1f) {
|
||||
Timber.v("Handle accountData")
|
||||
userAccountDataSyncHandler.handle(syncResponse.accountData, syncResponse.rooms?.invite)
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling accountData in $it ms")
|
||||
}
|
||||
|
||||
Timber.v("On sync completed")
|
||||
cryptoSyncHandler.onSyncCompleted(syncResponse)
|
||||
}.also {
|
||||
Timber.v("Finish handling rooms in $it ms")
|
||||
}
|
||||
Timber.v("Finish handling sync in $measure ms")
|
||||
syncResponse
|
||||
|
||||
|
||||
measureTimeMillis {
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_groups, 100, 0.1f) {
|
||||
Timber.v("Handle groups")
|
||||
if (syncResponse.groups != null) {
|
||||
groupSyncHandler.handle(syncResponse.groups, reporter)
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling groups in $it ms")
|
||||
}
|
||||
|
||||
measureTimeMillis {
|
||||
reportSubtask(reporter, R.string.initial_sync_start_importing_account_data, 100, 0.1f) {
|
||||
Timber.v("Handle accountData")
|
||||
userAccountDataSyncHandler.handle(syncResponse.accountData, syncResponse.rooms?.invite)
|
||||
}
|
||||
}.also {
|
||||
Timber.v("Finish handling accountData in $it ms")
|
||||
}
|
||||
|
||||
Timber.v("On sync completed")
|
||||
cryptoSyncHandler.onSyncCompleted(syncResponse)
|
||||
}
|
||||
Timber.v("Finish handling sync in $measure ms")
|
||||
}
|
||||
|
||||
}
|
|
@ -36,8 +36,7 @@ internal interface SyncTask : Task<SyncTask.Params, Unit> {
|
|||
}
|
||||
|
||||
internal class DefaultSyncTask @Inject constructor(private val syncAPI: SyncAPI,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val filterRepository: FilterRepository,
|
||||
private val syncResponseHandler: SyncResponseHandler,
|
||||
private val sessionParamsStore: SessionParamsStore,
|
||||
|
|
|
@ -39,8 +39,7 @@ import timber.log.Timber
|
|||
import javax.inject.Inject
|
||||
|
||||
internal class UserAccountDataSyncHandler @Inject constructor(private val monarchy: Monarchy,
|
||||
@UserId
|
||||
private val userId: String,
|
||||
@UserId private val userId: String,
|
||||
private val directChatsHelper: DirectChatsHelper,
|
||||
private val updateUserAccountDataTask: UpdateUserAccountDataTask,
|
||||
private val savePushRulesTask: SavePushRulesTask,
|
||||
|
|
|
@ -42,8 +42,7 @@ internal interface UpdateUserAccountDataTask : Task<UpdateUserAccountDataTask.Pa
|
|||
}
|
||||
|
||||
internal class DefaultUpdateUserAccountDataTask @Inject constructor(private val accountDataApi: AccountDataAPI,
|
||||
@UserId
|
||||
private val userId: String) : UpdateUserAccountDataTask {
|
||||
@UserId private val userId: String) : UpdateUserAccountDataTask {
|
||||
|
||||
override suspend fun execute(params: UpdateUserAccountDataTask.Params) {
|
||||
return executeRequest {
|
||||
|
|
Loading…
Reference in a new issue