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"
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user