}
public void checkAccountState() throws IOException {
+ if (account.getLastReceiveTimestamp() == 0) {
+ logger.warn("The Signal protocol expects that incoming messages are regularly received.");
+ } else {
+ var diffInMilliseconds = new Date().getTime() - account.getLastReceiveTimestamp();
+ long days = TimeUnit.DAYS.convert(diffInMilliseconds, TimeUnit.MILLISECONDS);
+ if (days > 7) {
+ logger.warn(
+ "Messages have been last received {} days ago. The Signal protocol expects that incoming messages are regularly received.",
+ days);
+ }
+ }
if (accountManager.getPreKeysCount() < ServiceConfig.PREKEY_MINIMUM_COUNT) {
refreshPreKeys();
}
SignalServiceContent content = null;
Exception exception = null;
final CachedMessage[] cachedMessage = {null};
+ account.setLastReceiveTimestamp(new Date().getTime());
try {
var result = messagePipe.readOrEmpty(timeout, unit, envelope1 -> {
final var recipientId = envelope1.hasSource()
private ProfileKey profileKey;
private int preKeyIdOffset;
private int nextSignedPreKeyId;
+ private long lastReceiveTimestamp = 0;
private boolean registered = false;
this.deviceId = deviceId;
this.registered = true;
this.isMultiDevice = true;
+ this.lastReceiveTimestamp = 0;
}
private void migrateLegacyConfigs() {
if (rootNode.hasNonNull("isMultiDevice")) {
isMultiDevice = rootNode.get("isMultiDevice").asBoolean();
}
+ if (rootNode.hasNonNull("lastReceiveTimestamp")) {
+ lastReceiveTimestamp = rootNode.get("lastReceiveTimestamp").asLong();
+ }
int registrationId = 0;
if (rootNode.hasNonNull("registrationId")) {
registrationId = rootNode.get("registrationId").asInt();
.put("deviceName", encryptedDeviceName)
.put("deviceId", deviceId)
.put("isMultiDevice", isMultiDevice)
+ .put("lastReceiveTimestamp", lastReceiveTimestamp)
.put("password", password)
.put("registrationId", identityKeyStore.getLocalRegistrationId())
.put("identityPrivateKey",
save();
}
+ public long getLastReceiveTimestamp() {
+ return lastReceiveTimestamp;
+ }
+
+ public void setLastReceiveTimestamp(final long lastReceiveTimestamp) {
+ this.lastReceiveTimestamp = lastReceiveTimestamp;
+ save();
+ }
+
public boolean isUnrestrictedUnidentifiedAccess() {
// TODO make configurable
return false;
this.registered = true;
this.uuid = uuid;
this.registrationLockPin = pin;
+ this.lastReceiveTimestamp = 0;
save();
getSessionStore().archiveAllSessions();