mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
parent
189b21dbde
commit
2e4cd0eddc
3 changed files with 21 additions and 16 deletions
|
@ -41,7 +41,6 @@ public class ReceiveHelper {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
private ReceiveConfig receiveConfig = new ReceiveConfig(false, false, false);
|
private ReceiveConfig receiveConfig = new ReceiveConfig(false, false, false);
|
||||||
private boolean needsToRetryFailedMessages = false;
|
|
||||||
private boolean hasCaughtUpWithOldMessages = false;
|
private boolean hasCaughtUpWithOldMessages = false;
|
||||||
private boolean isWaitingForMessage = false;
|
private boolean isWaitingForMessage = false;
|
||||||
private boolean shouldStop = false;
|
private boolean shouldStop = false;
|
||||||
|
@ -59,10 +58,6 @@ public class ReceiveHelper {
|
||||||
dependencies.setAllowStories(!receiveConfig.ignoreStories());
|
dependencies.setAllowStories(!receiveConfig.ignoreStories());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNeedsToRetryFailedMessages(final boolean needsToRetryFailedMessages) {
|
|
||||||
this.needsToRetryFailedMessages = needsToRetryFailedMessages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthenticationFailureListener(final Callable authenticationFailureListener) {
|
public void setAuthenticationFailureListener(final Callable authenticationFailureListener) {
|
||||||
this.authenticationFailureListener = authenticationFailureListener;
|
this.authenticationFailureListener = authenticationFailureListener;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +85,7 @@ public class ReceiveHelper {
|
||||||
public void receiveMessages(
|
public void receiveMessages(
|
||||||
Duration timeout, boolean returnOnTimeout, Integer maxMessages, Manager.ReceiveMessageHandler handler
|
Duration timeout, boolean returnOnTimeout, Integer maxMessages, Manager.ReceiveMessageHandler handler
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
needsToRetryFailedMessages = true;
|
account.setNeedsToRetryFailedMessages(true);
|
||||||
hasCaughtUpWithOldMessages = false;
|
hasCaughtUpWithOldMessages = false;
|
||||||
|
|
||||||
// Use a Map here because java Set doesn't have a get method ...
|
// Use a Map here because java Set doesn't have a get method ...
|
||||||
|
@ -130,9 +125,8 @@ public class ReceiveHelper {
|
||||||
isWaitingForMessage = false;
|
isWaitingForMessage = false;
|
||||||
|
|
||||||
while (!shouldStop && remainingMessages != 0) {
|
while (!shouldStop && remainingMessages != 0) {
|
||||||
if (needsToRetryFailedMessages) {
|
if (account.getNeedsToRetryFailedMessages()) {
|
||||||
retryFailedReceivedMessages(handler);
|
retryFailedReceivedMessages(handler);
|
||||||
needsToRetryFailedMessages = false;
|
|
||||||
}
|
}
|
||||||
SignalServiceEnvelope envelope;
|
SignalServiceEnvelope envelope;
|
||||||
final CachedMessage[] cachedMessage = {null};
|
final CachedMessage[] cachedMessage = {null};
|
||||||
|
@ -266,6 +260,7 @@ public class ReceiveHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleQueuedActions(queuedActions);
|
handleQueuedActions(queuedActions);
|
||||||
|
account.setNeedsToRetryFailedMessages(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<HandleAction> retryFailedReceivedMessage(
|
private List<HandleAction> retryFailedReceivedMessage(
|
||||||
|
@ -282,8 +277,8 @@ public class ReceiveHelper {
|
||||||
final var exception = result.second();
|
final var exception = result.second();
|
||||||
|
|
||||||
if (exception instanceof UntrustedIdentityException) {
|
if (exception instanceof UntrustedIdentityException) {
|
||||||
if (System.currentTimeMillis() - envelope.getServerDeliveredTimestamp() > 1000L * 60 * 60 * 24 * 30) {
|
if (System.currentTimeMillis() - envelope.getServerDeliveredTimestamp() > 1000L * 60 * 60 * 24 * 14) {
|
||||||
// Envelope is more than a month old, cleaning up.
|
// Envelope is more than two weeks old, cleaning up.
|
||||||
cachedMessage.delete();
|
cachedMessage.delete();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,8 +409,7 @@ public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitRateLimitRecaptchaChallenge(
|
public void submitRateLimitRecaptchaChallenge(
|
||||||
String challenge,
|
String challenge, String captcha
|
||||||
String captcha
|
|
||||||
) throws IOException, CaptchaRejectedException {
|
) throws IOException, CaptchaRejectedException {
|
||||||
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
||||||
|
|
||||||
|
@ -1389,7 +1388,7 @@ public class ManagerImpl implements Manager {
|
||||||
final var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
final var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
||||||
final var updated = trustMethod.apply(recipientId);
|
final var updated = trustMethod.apply(recipientId);
|
||||||
if (updated && this.isReceiving()) {
|
if (updated && this.isReceiving()) {
|
||||||
context.getReceiveHelper().setNeedsToRetryFailedMessages(true);
|
account.setNeedsToRetryFailedMessages(true);
|
||||||
}
|
}
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,9 @@ public class SignalAccount implements Closeable {
|
||||||
private final KeyValueEntry<Long> lastReceiveTimestamp = new KeyValueEntry<>("last-receive-timestamp",
|
private final KeyValueEntry<Long> lastReceiveTimestamp = new KeyValueEntry<>("last-receive-timestamp",
|
||||||
long.class,
|
long.class,
|
||||||
0L);
|
0L);
|
||||||
|
private final KeyValueEntry<Boolean> needsToRetryFailedMessages = new KeyValueEntry<>("retry-failed-messages",
|
||||||
|
Boolean.class,
|
||||||
|
true);
|
||||||
private final KeyValueEntry<byte[]> cdsiToken = new KeyValueEntry<>("cdsi-token", byte[].class);
|
private final KeyValueEntry<byte[]> cdsiToken = new KeyValueEntry<>("cdsi-token", byte[].class);
|
||||||
private final KeyValueEntry<Long> lastRecipientsRefresh = new KeyValueEntry<>("last-recipients-refresh",
|
private final KeyValueEntry<Long> lastRecipientsRefresh = new KeyValueEntry<>("last-recipients-refresh",
|
||||||
long.class);
|
long.class);
|
||||||
|
@ -297,7 +300,7 @@ public class SignalAccount implements Closeable {
|
||||||
this.pniAccountData.setIdentityKeyPair(pniIdentity);
|
this.pniAccountData.setIdentityKeyPair(pniIdentity);
|
||||||
this.registered = false;
|
this.registered = false;
|
||||||
this.isMultiDevice = true;
|
this.isMultiDevice = true;
|
||||||
getKeyValueStore().storeEntry(lastReceiveTimestamp, 0L);
|
setLastReceiveTimestamp(0L);
|
||||||
this.pinMasterKey = masterKey;
|
this.pinMasterKey = masterKey;
|
||||||
getKeyValueStore().storeEntry(storageManifestVersion, -1L);
|
getKeyValueStore().storeEntry(storageManifestVersion, -1L);
|
||||||
this.setStorageManifest(null);
|
this.setStorageManifest(null);
|
||||||
|
@ -342,7 +345,7 @@ public class SignalAccount implements Closeable {
|
||||||
this.pniAccountData.setServiceId(pni);
|
this.pniAccountData.setServiceId(pni);
|
||||||
init();
|
init();
|
||||||
this.registrationLockPin = pin;
|
this.registrationLockPin = pin;
|
||||||
getKeyValueStore().storeEntry(lastReceiveTimestamp, 0L);
|
setLastReceiveTimestamp(0L);
|
||||||
save();
|
save();
|
||||||
|
|
||||||
setPreKeys(ServiceIdType.ACI, aciPreKeys);
|
setPreKeys(ServiceIdType.ACI, aciPreKeys);
|
||||||
|
@ -590,7 +593,7 @@ public class SignalAccount implements Closeable {
|
||||||
isMultiDevice = rootNode.get("isMultiDevice").asBoolean();
|
isMultiDevice = rootNode.get("isMultiDevice").asBoolean();
|
||||||
}
|
}
|
||||||
if (rootNode.hasNonNull("lastReceiveTimestamp")) {
|
if (rootNode.hasNonNull("lastReceiveTimestamp")) {
|
||||||
getKeyValueStore().storeEntry(lastReceiveTimestamp, rootNode.get("lastReceiveTimestamp").asLong());
|
setLastReceiveTimestamp(rootNode.get("lastReceiveTimestamp").asLong());
|
||||||
}
|
}
|
||||||
int registrationId = 0;
|
int registrationId = 0;
|
||||||
if (rootNode.hasNonNull("registrationId")) {
|
if (rootNode.hasNonNull("registrationId")) {
|
||||||
|
@ -1650,6 +1653,14 @@ public class SignalAccount implements Closeable {
|
||||||
getKeyValueStore().storeEntry(lastReceiveTimestamp, value);
|
getKeyValueStore().storeEntry(lastReceiveTimestamp, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNeedsToRetryFailedMessages(final boolean value) {
|
||||||
|
getKeyValueStore().storeEntry(needsToRetryFailedMessages, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getNeedsToRetryFailedMessages() {
|
||||||
|
return getKeyValueStore().getEntry(needsToRetryFailedMessages);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUnrestrictedUnidentifiedAccess() {
|
public boolean isUnrestrictedUnidentifiedAccess() {
|
||||||
return Boolean.TRUE.equals(getKeyValueStore().getEntry(unrestrictedUnidentifiedAccess));
|
return Boolean.TRUE.equals(getKeyValueStore().getEntry(unrestrictedUnidentifiedAccess));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue