Add server time to remote config fetch

Enable clients to very roughly adjust some actions for clock skew by
providing current server time in the remote config fetch.
This commit is contained in:
Ehren Kret 2023-06-21 16:08:46 -05:00
parent 0122b410be
commit cc3cab9c88
2 changed files with 14 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Clock;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -91,7 +92,7 @@ public class RemoteConfigController {
config.getUuids());
return new UserRemoteConfig(config.getName(), inBucket,
inBucket ? config.getValue() : config.getDefaultValue());
}), globalConfigStream).collect(Collectors.toList()));
}), globalConfigStream).collect(Collectors.toList()), Clock.systemUTC().instant());
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}

View File

@ -5,8 +5,10 @@
package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.Instant;
import java.util.List;
public class UserRemoteConfigList {
@ -14,13 +16,22 @@ public class UserRemoteConfigList {
@JsonProperty
private List<UserRemoteConfig> config;
@JsonProperty
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
private Instant serverEpochTime;
public UserRemoteConfigList() {}
public UserRemoteConfigList(List<UserRemoteConfig> config) {
public UserRemoteConfigList(List<UserRemoteConfig> config, Instant serverEpochTime) {
this.config = config;
this.serverEpochTime = serverEpochTime;
}
public List<UserRemoteConfig> getConfig() {
return config;
}
public Instant getServerEpochTime() {
return serverEpochTime;
}
}