Add support for app version-based remote configs.

This commit is contained in:
jeffrey-signal
2026-03-06 16:44:06 -05:00
parent a64b77d6f2
commit 9500f4a59c
2 changed files with 24 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import org.signal.core.util.gibiBytes
import org.signal.core.util.kibiBytes
import org.signal.core.util.logging.Log
import org.signal.core.util.mebiBytes
import org.thoughtcrime.securesms.BuildConfig
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.groups.SelectionLimits
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
@@ -521,6 +522,24 @@ object RemoteConfig {
)
}
/**
* A config that evaluates to true when the app's version is >= the semantic version string (e.g. "8.2.0") stored in the remote config value.
*
* Returns false if the remote value is absent, empty, or unparseable.
*/
@Suppress("SameParameterValue")
private fun remoteMinVersion(
key: String
): Config<Boolean> = remoteValue(
key = key,
hotSwappable = true,
transformer = { value ->
val minVersion = SemanticVersion.parse(value.asString(null))
val appVersion = SemanticVersion.parse(BuildConfig.VERSION_NAME.substringBefore("-"))
minVersion != null && appVersion != null && appVersion >= minVersion
}
)
private fun <T> remoteValue(
key: String,
hotSwappable: Boolean,
@@ -1273,10 +1292,8 @@ object RemoteConfig {
*/
@JvmStatic
@get:JvmName("sendMemberLabels")
val sendMemberLabels: Boolean by remoteBoolean(
key = "android.sendMemberLabels.3",
defaultValue = false,
hotSwappable = true
val sendMemberLabels: Boolean by remoteMinVersion(
key = "android.sendMemberLabels.4"
)
/**

View File

@@ -9,6 +9,7 @@ import kotlin.reflect.full.memberProperties
/**
* Ensures we don't release with forced values which is intended for local development only.
*/
@Suppress("ClassName")
class RemoteConfig_StaticValuesTest {
@Before
@@ -35,7 +36,8 @@ class RemoteConfig_StaticValuesTest {
"1",
"100",
"12345678910111213141516",
"*"
"*",
"1.0.0"
)
val configKeys = RemoteConfig.configsByKey.keys