Add support for remote feature flags.

This commit is contained in:
Greyson Parrelli
2019-12-19 17:41:21 -05:00
parent b8602ee004
commit 55e9f8722f
33 changed files with 403 additions and 58 deletions

View File

@@ -43,6 +43,7 @@ import org.whispersystems.signalservice.internal.crypto.ProvisioningCipher;
import org.whispersystems.signalservice.internal.push.ProfileAvatarData;
import org.whispersystems.signalservice.internal.push.PushServiceSocket;
import org.whispersystems.signalservice.internal.push.RemoteAttestationUtil;
import org.whispersystems.signalservice.internal.push.RemoteConfigResponse;
import org.whispersystems.signalservice.internal.push.http.ProfileCipherOutputStreamFactory;
import org.whispersystems.signalservice.internal.storage.protos.ManifestRecord;
import org.whispersystems.signalservice.internal.storage.protos.ReadOperation;
@@ -501,6 +502,16 @@ public class SignalServiceAccountManager {
}
}
public Map<String, Boolean> getRemoteConfig() throws IOException {
RemoteConfigResponse response = this.pushServiceSocket.getRemoteConfig();
Map<String, Boolean> out = new HashMap<>();
for (RemoteConfigResponse.Config config : response.getConfig()) {
out.put(config.getName(), config.isEnabled());
}
return out;
}
public String getNewDeviceVerificationCode() throws IOException {

View File

@@ -731,6 +731,11 @@ public class PushServiceSocket {
}
}
public RemoteConfigResponse getRemoteConfig() throws IOException {
String response = makeServiceRequest("/v1/config", "GET", null);
return JsonUtil.fromJson(response, RemoteConfigResponse.class);
}
public void setSoTimeoutMillis(long soTimeoutMillis) {
this.soTimeoutMillis = soTimeoutMillis;
}

View File

@@ -0,0 +1,30 @@
package org.whispersystems.signalservice.internal.push;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class RemoteConfigResponse {
@JsonProperty
private List<Config> config;
public List<Config> getConfig() {
return config;
}
public static class Config {
@JsonProperty
private String name;
@JsonProperty
private boolean enabled;
public String getName() {
return name;
}
public boolean isEnabled() {
return enabled;
}
}
}