Tweak Network.transformAndSetRemoteConfig to match changes to libsignal's RemoteConfig spec.

This commit is contained in:
andrew-signal
2025-04-17 12:01:37 -04:00
committed by Cody Henthorne
parent 48d26beb77
commit 8b7b184224

View File

@@ -16,12 +16,11 @@ import java.io.IOException
private const val TAG = "LibSignalNetworkExtensions" private const val TAG = "LibSignalNetworkExtensions"
fun Network.transformAndSetRemoteConfig(remoteConfig: Map<String, Any>) { fun Network.transformAndSetRemoteConfig(remoteConfig: Map<String, Any>) {
val libsignalRemoteConfig = HashMap<String, String>() val libsignalRemoteConfig: Map<String, String> = remoteConfig
for (key in remoteConfig.keys) { .filterKeys { it.startsWith("android.libsignal.") }
if (key.startsWith("android.libsignal.") or key.startsWith("global.libsignal.")) { .mapKeys { (k, _) -> k.removePrefix("android.libsignal.") }
libsignalRemoteConfig[key] = JsonUtil.toJson(remoteConfig[key]) // libsignal-net's RemoteConfig diverges from JSON-spec by not quoting string values.
} .mapValues { (_, v) -> (v as? String) ?: JsonUtil.toJson(v) }
}
this.setRemoteConfig(libsignalRemoteConfig) this.setRemoteConfig(libsignalRemoteConfig)
} }