From e362cad3126f18c50f2b624e718b25e43f680933 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 28 Oct 2024 11:00:34 +0000 Subject: [PATCH] Enable identity pinning violation notifications unconditionally (Remove the feature flag we added when this feature seemed unstable.) --- .../identity/IdentityChangeStatePresenter.kt | 9 +--- .../IdentityChangeStatePresenterTest.kt | 46 ------------------- .../libraries/featureflag/api/FeatureFlags.kt | 16 +------ 3 files changed, 2 insertions(+), 69 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenter.kt index 16bc39fac8..3b56fc9993 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenter.kt @@ -15,8 +15,6 @@ import androidx.compose.runtime.rememberCoroutineScope import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.components.avatar.AvatarSize -import io.element.android.libraries.featureflag.api.FeatureFlagService -import io.element.android.libraries.featureflag.api.FeatureFlags import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.api.encryption.EncryptionService import io.element.android.libraries.matrix.api.room.MatrixRoom @@ -41,7 +39,6 @@ import javax.inject.Inject class IdentityChangeStatePresenter @Inject constructor( private val room: MatrixRoom, private val encryptionService: EncryptionService, - private val featureFlagService: FeatureFlagService, ) : Presenter { @Composable override fun present(): IdentityChangeState { @@ -64,11 +61,7 @@ class IdentityChangeStatePresenter @Inject constructor( @OptIn(ExperimentalCoroutinesApi::class) private fun ProduceStateScope>.observeRoomMemberIdentityStateChange() { - featureFlagService.isFeatureEnabledFlow(FeatureFlags.IdentityPinningViolationNotifications) - .filter { it } - .flatMapLatest { - room.syncUpdateFlow - } + room.syncUpdateFlow .filter { // Room cannot become unencrypted, so we can just apply a filter here. room.isEncrypted diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenterTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenterTest.kt index 92774f4feb..f87c727379 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenterTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/crypto/identity/IdentityChangeStatePresenterTest.kt @@ -9,9 +9,6 @@ package io.element.android.features.messages.impl.crypto.identity import com.google.common.truth.Truth.assertThat import io.element.android.libraries.designsystem.components.avatar.AvatarSize -import io.element.android.libraries.featureflag.api.FeatureFlagService -import io.element.android.libraries.featureflag.api.FeatureFlags -import io.element.android.libraries.featureflag.test.FakeFeatureFlagService import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.api.encryption.EncryptionService import io.element.android.libraries.matrix.api.encryption.identity.IdentityState @@ -68,43 +65,6 @@ class IdentityChangeStatePresenterTest { } } - @Test - fun `present - when the room emits identity change, but the feature is disabled, the presenter does not emit new state`() = runTest { - val room = FakeMatrixRoom( - isEncrypted = true, - ) - val featureFlagService = FakeFeatureFlagService( - initialState = mapOf( - FeatureFlags.IdentityPinningViolationNotifications.key to false, - ) - ) - val presenter = createIdentityChangeStatePresenter( - room = room, - featureFlagService = featureFlagService, - ) - presenter.test { - val initialState = awaitItem() - assertThat(initialState.roomMemberIdentityStateChanges).isEmpty() - room.emitIdentityStateChanges( - listOf( - IdentityStateChange( - userId = A_USER_ID_2, - identityState = IdentityState.PinViolation, - ), - ) - ) - // No item emitted. - expectNoEvents() - // Enable the feature - featureFlagService.setFeatureEnabled(FeatureFlags.IdentityPinningViolationNotifications, true) - val finalItem = awaitItem() - assertThat(finalItem.roomMemberIdentityStateChanges).hasSize(1) - val value = finalItem.roomMemberIdentityStateChanges.first() - assertThat(value.identityRoomMember.userId).isEqualTo(A_USER_ID_2) - assertThat(value.identityState).isEqualTo(IdentityState.PinViolation) - } - } - @Test fun `present - when the clear room emits identity change, the presenter does not emit new state`() = runTest { val room = FakeMatrixRoom(isEncrypted = false) @@ -188,16 +148,10 @@ class IdentityChangeStatePresenterTest { private fun createIdentityChangeStatePresenter( room: MatrixRoom = FakeMatrixRoom(), encryptionService: EncryptionService = FakeEncryptionService(), - featureFlagService: FeatureFlagService = FakeFeatureFlagService( - initialState = mapOf( - FeatureFlags.IdentityPinningViolationNotifications.key to true, - ) - ), ): IdentityChangeStatePresenter { return IdentityChangeStatePresenter( room = room, encryptionService = encryptionService, - featureFlagService = featureFlagService, ) } } diff --git a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt index 3a6bd16f77..1a8b8935b4 100644 --- a/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt +++ b/libraries/featureflag/api/src/main/kotlin/io/element/android/libraries/featureflag/api/FeatureFlags.kt @@ -9,7 +9,6 @@ package io.element.android.libraries.featureflag.api import io.element.android.appconfig.OnBoardingConfig import io.element.android.libraries.core.meta.BuildMeta -import io.element.android.libraries.core.meta.BuildType /** * To enable or disable a FeatureFlags, change the `defaultValue` value. @@ -125,18 +124,5 @@ enum class FeatureFlags( " You'll have to stop and re-open the app manually for that setting to take effect.", defaultValue = { false }, isFinished = false, - ), - IdentityPinningViolationNotifications( - key = "feature.identityPinningViolationNotifications", - title = "Identity pinning violation notifications", - description = null, - defaultValue = { buildMeta -> - when (buildMeta.buildType) { - // Do not enable this feature in release builds - BuildType.RELEASE -> false - else -> true - } - }, - isFinished = false, - ), + ) }