Skip to content

Commit

Permalink
Add server time to remote config fetch
Browse files Browse the repository at this point in the history
Enable clients to very roughly adjust some actions for clock skew by
providing current server time in the remote config fetch.
  • Loading branch information
ehrenkret-signal committed Jun 21, 2023
1 parent 0122b41 commit cc3cab9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -91,7 +92,7 @@ public UserRemoteConfigList getAll(@Auth AuthenticatedAccount auth) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@

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 {

@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;
}
}

0 comments on commit cc3cab9

Please sign in to comment.