mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Tweak Network.transformAndSetRemoteConfig to match changes to libsignal's RemoteConfig spec.
This commit is contained in:
committed by
Cody Henthorne
parent
48d26beb77
commit
8b7b184224
@@ -16,12 +16,11 @@ import java.io.IOException
|
||||
private const val TAG = "LibSignalNetworkExtensions"
|
||||
|
||||
fun Network.transformAndSetRemoteConfig(remoteConfig: Map<String, Any>) {
|
||||
val libsignalRemoteConfig = HashMap<String, String>()
|
||||
for (key in remoteConfig.keys) {
|
||||
if (key.startsWith("android.libsignal.") or key.startsWith("global.libsignal.")) {
|
||||
libsignalRemoteConfig[key] = JsonUtil.toJson(remoteConfig[key])
|
||||
}
|
||||
}
|
||||
val libsignalRemoteConfig: Map<String, String> = remoteConfig
|
||||
.filterKeys { it.startsWith("android.libsignal.") }
|
||||
.mapKeys { (k, _) -> k.removePrefix("android.libsignal.") }
|
||||
// libsignal-net's RemoteConfig diverges from JSON-spec by not quoting string values.
|
||||
.mapValues { (_, v) -> (v as? String) ?: JsonUtil.toJson(v) }
|
||||
|
||||
this.setRemoteConfig(libsignalRemoteConfig)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user