-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable status update for private users (#2202)
* implement sync migration logic and migrate to 7 * add unit tests * detekt * detekt * add test for the order of migration steps * move migration to the top of the execution sync stack and add more tests * fix test * address PR comments * detekt * add docs
- Loading branch information
1 parent
cdf5567
commit 83cdfef
Showing
19 changed files
with
720 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/slow/SlowSyncParam.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.sync.slow | ||
|
||
sealed interface SlowSyncParam { | ||
data object Success : SlowSyncParam | ||
data object NotPerformedBefore : SlowSyncParam | ||
data object LastSlowSyncTooOld : SlowSyncParam | ||
data class MigrationNeeded(val oldVersion: Int, val newVersion: Int) : SlowSyncParam | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...commonMain/kotlin/com/wire/kalium/logic/sync/slow/migration/SyncMigrationStepsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.sync.slow.migration | ||
|
||
import com.wire.kalium.logic.data.id.SelfTeamIdProvider | ||
import com.wire.kalium.logic.data.user.AccountRepository | ||
import com.wire.kalium.logic.sync.slow.migration.steps.SyncMigrationStep | ||
import com.wire.kalium.logic.sync.slow.migration.steps.SyncMigrationStep_6_7 | ||
|
||
internal interface SyncMigrationStepsProvider { | ||
fun getMigrationSteps(fromVersion: Int, toVersion: Int): List<SyncMigrationStep> | ||
} | ||
|
||
@Suppress("MagicNumber") | ||
internal class SyncMigrationStepsProviderImpl( | ||
accountRepository: Lazy<AccountRepository>, | ||
selfTeamIdProvider: SelfTeamIdProvider | ||
) : SyncMigrationStepsProvider { | ||
|
||
private val steps = mapOf( | ||
7 to lazy { SyncMigrationStep_6_7(accountRepository, selfTeamIdProvider) } | ||
) | ||
|
||
override fun getMigrationSteps(fromVersion: Int, toVersion: Int): List<SyncMigrationStep> { | ||
return steps | ||
.filter { it.key in (fromVersion + 1)..toVersion }.values | ||
.sortedBy { it.value.version } | ||
.map { it.value } | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...rc/commonMain/kotlin/com/wire/kalium/logic/sync/slow/migration/steps/SyncMigrationStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.sync.slow.migration.steps | ||
|
||
import com.wire.kalium.logic.CoreFailure | ||
import com.wire.kalium.logic.functional.Either | ||
|
||
/** | ||
* Migration step. | ||
* this interface provide a way to migrate the sync version of the user. | ||
* the logic is executed before sync itself | ||
* keep in mind this logic can run multiple times | ||
* since it runs before sync then if one of the sync steps after it failed, | ||
* and we need to retry sync then this logic will run again | ||
* @property version The sync version after executing this migration step. | ||
* @property invoke The migration step itself | ||
*/ | ||
internal interface SyncMigrationStep { | ||
val version: Int | ||
suspend operator fun invoke(): Either<CoreFailure, Unit> | ||
} |
Oops, something went wrong.