Skip to content

fix: fetch MLS public keys the same way as feature config [WPB-17161] #3991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a20227
chore: disable picture in picture
MohamadJaara Mar 13, 2025
478667b
fix: broken test for AnonymousAnalyticsManagerTest
yamilmedina Mar 17, 2025
5f4ebf7
fix: broken class ExternalLoggerManager for flavor
yamilmedina Mar 17, 2025
af6cb19
fix: broken tests for flavored runs
yamilmedina Mar 17, 2025
ca62a1a
fix: disable in-call reactions while connecting [WPB-16372] (#3916)
saleniuk Mar 18, 2025
63637e3
fix: crashes on audio message playback [WPB-16195] (#3917)
saleniuk Mar 19, 2025
a6254ef
chore: run connected tests on dev flavour [WPB-16596] (#3925)
MohamadJaara Mar 19, 2025
a57eadc
fix: persist self email to register device with 2fa [WPB-16573] (#3929)
saleniuk Mar 20, 2025
2166088
chore: update kalium
MohamadJaara Mar 25, 2025
63a7f60
fix: app crashing when sharing location form a modified version of an…
MohamadJaara Mar 26, 2025
0fe8ab1
fix: analytics should be disabled for c-builds (WPB-16675) (#3940)
yamilmedina Mar 27, 2025
b843e93
fix: handle 2fa on RegisterDeviceScreen [WPB-16573] (#3934)
saleniuk Mar 28, 2025
e0fce29
chore: update kalium
MohamadJaara Mar 31, 2025
e6bc0f6
chore: release notes for 4.11.0
MohamadJaara Mar 31, 2025
4cf7ca3
fix: compare versions in the build script
MohamadJaara Mar 31, 2025
5c4e3d8
chore: bump version to 4.11.1
MohamadJaara Apr 1, 2025
42e658b
chore: update kalium
MohamadJaara Apr 1, 2025
073894e
fix: prod builder script not running
MohamadJaara Apr 1, 2025
d8912c3
fix: prod builder script not running
MohamadJaara Apr 1, 2025
360acc6
fix: prod builder script not running
MohamadJaara Apr 1, 2025
add996f
feat: database optimizer [WPB-16842] (#3950)
Garzas Apr 2, 2025
58ae553
fix: audio recording and playing crashes [WPB-16687] [WPB-16835] (#3955)
saleniuk Apr 2, 2025
64909ed
Revert "chore: bump version to 4.11.1"
MohamadJaara Apr 2, 2025
5d77493
chore: bump upload artifact action
MohamadJaara Apr 2, 2025
5e618ca
chore: bump version to 4.11.1
MohamadJaara Apr 9, 2025
00c3613
fix: make sure coroutine is init before using it on analytics manager…
yamilmedina Apr 9, 2025
075cb91
test: speed up tests [WPB-8645] (#3964)
vitorhugods Apr 4, 2025
3a369c8
chore: update kalium
saleniuk Apr 11, 2025
7601617
chore: bump core crypto to 3.1.1
MohamadJaara Apr 15, 2025
e763dff
fix: fetch MLS public keys the same way as feature config [WPB-17161]
saleniuk Apr 15, 2025
57ef726
Merge remote-tracking branch 'refs/remotes/origin/release/candidate' …
saleniuk Apr 15, 2025
8aea3d5
Merge remote-tracking branch 'origin/develop' into fix/fetch-mls-publ…
saleniuk Jun 17, 2025
443d4ef
Merge remote-tracking branch 'origin/develop' into fix/fetch-mls-publ…
saleniuk Jun 17, 2025
7fee3f7
update kalium ref
saleniuk Jun 17, 2025
61c08a3
remove code added improperly during merge
saleniuk Jun 17, 2025
9afe3ae
Merge remote-tracking branch 'origin/develop' into fix/fetch-mls-publ…
saleniuk Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.wire.kalium.logic.feature.e2ei.usecase.GetUserMlsClientIdentitiesUseC
import com.wire.kalium.logic.feature.e2ei.usecase.IsOtherUserE2EIVerifiedUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.ObserveCertificateRevocationForSelfClientUseCase
import com.wire.kalium.logic.feature.featureConfig.FeatureFlagsSyncWorker
import com.wire.kalium.logic.feature.mls.MLSPublicKeysSyncWorker
import com.wire.kalium.logic.feature.personaltoteamaccount.CanMigrateFromPersonalToTeamUseCase
import com.wire.kalium.logic.feature.publicuser.GetAllContactsUseCase
import com.wire.kalium.logic.feature.publicuser.GetKnownUserUseCase
Expand Down Expand Up @@ -256,4 +257,9 @@ class UserModule {
@Provides
fun provideObserveCertificateRevocationForSelfClientUseCase(userScope: UserScope): ObserveCertificateRevocationForSelfClientUseCase =
userScope.observeCertificateRevocationForSelfClient

@ViewModelScoped
@Provides
fun provideMLSPublicKeysSyncWorker(userScope: UserScope): MLSPublicKeysSyncWorker =
userScope.mlsPublicKeysSyncWorker
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.wire.kalium.logic.feature.e2ei.SyncCertificateRevocationListUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.ObserveCertificateRevocationForSelfClientUseCase
import com.wire.kalium.logic.feature.featureConfig.FeatureFlagsSyncWorker
import com.wire.kalium.logic.feature.mlsmigration.MLSMigrationManager
import com.wire.kalium.logic.feature.mls.MLSPublicKeysSyncWorker
import com.wire.kalium.logic.feature.server.UpdateApiVersionsUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Job
Expand All @@ -43,6 +44,7 @@ class AppSyncViewModel @Inject constructor(
private val syncCertificateRevocationListUseCase: SyncCertificateRevocationListUseCase,
private val observeCertificateRevocationForSelfClient: ObserveCertificateRevocationForSelfClientUseCase,
private val featureFlagsSyncWorker: FeatureFlagsSyncWorker,
private val mlsPublicKeysSyncWorker: MLSPublicKeysSyncWorker,
private val updateApiVersions: UpdateApiVersionsUseCase,
private val mLSMigrationManager: MLSMigrationManager,
private val keyingMaterialsManager: KeyingMaterialsManager,
Expand Down Expand Up @@ -83,6 +85,7 @@ class AppSyncViewModel @Inject constructor(
listOf(
viewModelScope.launch(dispatcher.io()) { syncCertificateRevocationListUseCase() },
viewModelScope.launch(dispatcher.io()) { featureFlagsSyncWorker.execute() },
viewModelScope.launch(dispatcher.io()) { mlsPublicKeysSyncWorker.executeImmediately() },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure this whole block of runSyncTasks() here was just a quick hack and now it is getting expanded further.

App knows too much about this.

We should either:
A. Launch mlsPublicKeysSyncWorker when UserSessionScope starts, and have it wait for Sync to be LIVE before doing anything else. Once LIVE it will do its thing, be it on the background or not. And it can reschedule itself to repeat every 24h if still running.
B. Create a ForegroundWorker of some sorts in Kalium, so the app would call it and Kalium would take over.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitorhugods should I do it as part of this ticket or should we create a dedicated one to clear this up?

Copy link
Contributor Author

@saleniuk saleniuk Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states that it should be called each time the user puts the app in the foreground, so running it each time the app becomes LIVE is not exactly the same.
And it actually waits until live when being executed, this logic is implemented already inside this worker, just like for feature flag sync worker and proteus sync worker.
About B idea, I don't know if I get it correctly but the only change would be that the app starts this single ForegroundWorker instead of starting each one separately?

viewModelScope.launch(dispatcher.io()) { observeCertificateRevocationForSelfClient.invoke() },
viewModelScope.launch(dispatcher.io()) { updateApiVersions() },
viewModelScope.launch(dispatcher.io()) { mLSClientManager() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.wire.kalium.logic.feature.e2ei.SyncCertificateRevocationListUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.ObserveCertificateRevocationForSelfClientUseCase
import com.wire.kalium.logic.feature.featureConfig.FeatureFlagsSyncWorker
import com.wire.kalium.logic.feature.mlsmigration.MLSMigrationManager
import com.wire.kalium.logic.feature.mls.MLSPublicKeysSyncWorker
import com.wire.kalium.logic.feature.server.UpdateApiVersionsUseCase
import io.mockk.MockKAnnotations
import io.mockk.coEvery
Expand All @@ -45,6 +46,7 @@ class AppSyncViewModelTest {
val (arrangement, viewModel) = Arrangement().arrange(testDispatcher) {
withObserveCertificateRevocationForSelfClient()
withFeatureFlagsSyncWorker()
withMLSPublicKeysSyncWorker()
withSyncCertificateRevocationListUseCase()
withUpdateApiVersions()
withMlsClientManager()
Expand All @@ -58,6 +60,7 @@ class AppSyncViewModelTest {
coVerify { arrangement.observeCertificateRevocationForSelfClient.invoke() }
coVerify { arrangement.syncCertificateRevocationListUseCase.invoke() }
coVerify { arrangement.featureFlagsSyncWorker.execute() }
coVerify { arrangement.mlsPublicKeysSyncWorker.executeImmediately() }
coVerify { arrangement.updateApiVersions() }
coVerify { arrangement.mlsClientManager() }
coVerify { arrangement.mlsMigrationManager() }
Expand All @@ -69,6 +72,7 @@ class AppSyncViewModelTest {
val (arrangement, viewModel) = Arrangement().arrange(testDispatcher) {
withObserveCertificateRevocationForSelfClient(1000)
withFeatureFlagsSyncWorker(1000)
withMLSPublicKeysSyncWorker(1000)
withSyncCertificateRevocationListUseCase(1000)
withUpdateApiVersions(1000)
withMlsClientManager(1000)
Expand All @@ -84,6 +88,7 @@ class AppSyncViewModelTest {
coVerify(exactly = 1) { arrangement.observeCertificateRevocationForSelfClient.invoke() }
coVerify(exactly = 1) { arrangement.syncCertificateRevocationListUseCase.invoke() }
coVerify(exactly = 1) { arrangement.featureFlagsSyncWorker.execute() }
coVerify(exactly = 1) { arrangement.mlsPublicKeysSyncWorker.executeImmediately() }
coVerify(exactly = 1) { arrangement.updateApiVersions() }
coVerify(exactly = 1) { arrangement.mlsClientManager() }
coVerify(exactly = 1) { arrangement.mlsMigrationManager() }
Expand All @@ -101,6 +106,9 @@ class AppSyncViewModelTest {
@MockK
lateinit var featureFlagsSyncWorker: FeatureFlagsSyncWorker

@MockK
lateinit var mlsPublicKeysSyncWorker: MLSPublicKeysSyncWorker

@MockK
lateinit var updateApiVersions: UpdateApiVersionsUseCase

Expand Down Expand Up @@ -135,6 +143,12 @@ class AppSyncViewModelTest {
}
}

fun withMLSPublicKeysSyncWorker(delayMs: Long = 0) {
coEvery { mlsPublicKeysSyncWorker.executeImmediately() } coAnswers {
delay(delayMs)
}
}

fun withUpdateApiVersions(delayMs: Long = 0) {
coEvery { updateApiVersions() } coAnswers {
delay(delayMs)
Expand All @@ -161,10 +175,11 @@ class AppSyncViewModelTest {

fun arrange(testDispatcher: TestDispatcherProvider, block: Arrangement.() -> Unit) = apply(block).let {
this to AppSyncViewModel(
syncCertificateRevocationListUseCase,
observeCertificateRevocationForSelfClient,
featureFlagsSyncWorker,
updateApiVersions,
syncCertificateRevocationListUseCase = syncCertificateRevocationListUseCase,
observeCertificateRevocationForSelfClient = observeCertificateRevocationForSelfClient,
featureFlagsSyncWorker = featureFlagsSyncWorker,
mlsPublicKeysSyncWorker = mlsPublicKeysSyncWorker,
updateApiVersions = updateApiVersions,
mLSClientManager = mlsClientManager,
mLSMigrationManager = mlsMigrationManager,
keyingMaterialsManager = keyingMaterialsManager,
Expand Down
Loading