mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Do a full recipients refresh every day
This commit is contained in:
parent
505de39d2a
commit
dd3326f038
3 changed files with 26 additions and 0 deletions
|
@ -214,6 +214,7 @@ public class RecipientHelper {
|
|||
}};
|
||||
account.getCdsiStore().updateAfterFullCdsQuery(fullNumbers, seenNumbers);
|
||||
account.setCdsiToken(newToken);
|
||||
account.setLastRecipientsRefresh(System.currentTimeMillis());
|
||||
}
|
||||
});
|
||||
} catch (CdsiInvalidTokenException e) {
|
||||
|
|
|
@ -115,6 +115,7 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Function;
|
||||
|
@ -215,6 +216,18 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
public void checkAccountState() throws IOException {
|
||||
context.getAccountHelper().checkAccountState();
|
||||
final var lastRecipientsRefresh = account.getLastRecipientsRefresh();
|
||||
if (lastRecipientsRefresh == null
|
||||
|| lastRecipientsRefresh < System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)) {
|
||||
try {
|
||||
context.getRecipientHelper().refreshUsers();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Full CDSI recipients refresh failed, ignoring: {} ({})",
|
||||
e.getMessage(),
|
||||
e.getClass().getSimpleName());
|
||||
logger.debug("Full CDSI refresh failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -147,6 +147,8 @@ public class SignalAccount implements Closeable {
|
|||
long.class,
|
||||
0L);
|
||||
private final KeyValueEntry<byte[]> cdsiToken = new KeyValueEntry<>("cdsi-token", byte[].class);
|
||||
private final KeyValueEntry<Long> lastRecipientsRefresh = new KeyValueEntry<>("last-recipients-refresh",
|
||||
long.class);
|
||||
private final KeyValueEntry<Long> storageManifestVersion = new KeyValueEntry<>("storage-manifest-version",
|
||||
long.class,
|
||||
-1L);
|
||||
|
@ -374,6 +376,7 @@ public class SignalAccount implements Closeable {
|
|||
this.storageKey = null;
|
||||
trustSelfIdentity(ServiceIdType.ACI);
|
||||
trustSelfIdentity(ServiceIdType.PNI);
|
||||
getKeyValueStore().storeEntry(lastRecipientsRefresh, null);
|
||||
}
|
||||
|
||||
public void finishRegistration(
|
||||
|
@ -406,6 +409,7 @@ public class SignalAccount implements Closeable {
|
|||
getRecipientTrustedResolver().resolveSelfRecipientTrusted(getSelfRecipientAddress());
|
||||
trustSelfIdentity(ServiceIdType.ACI);
|
||||
trustSelfIdentity(ServiceIdType.PNI);
|
||||
getKeyValueStore().storeEntry(lastRecipientsRefresh, null);
|
||||
}
|
||||
|
||||
public void initDatabase() {
|
||||
|
@ -1586,6 +1590,14 @@ public class SignalAccount implements Closeable {
|
|||
getKeyValueStore().storeEntry(cdsiToken, value);
|
||||
}
|
||||
|
||||
public Long getLastRecipientsRefresh() {
|
||||
return getKeyValueStore().getEntry(lastRecipientsRefresh);
|
||||
}
|
||||
|
||||
public void setLastRecipientsRefresh(final Long value) {
|
||||
getKeyValueStore().storeEntry(lastRecipientsRefresh, value);
|
||||
}
|
||||
|
||||
public ProfileKey getProfileKey() {
|
||||
return profileKey;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue