mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add --ignore-stories flag to prevent receiving story messages
This commit is contained in:
parent
3f7d8c60b9
commit
9ffacfe90e
8 changed files with 51 additions and 20 deletions
|
@ -40,6 +40,8 @@ public class SignalDependencies {
|
|||
private final ExecutorService executor;
|
||||
private final SignalSessionLock sessionLock;
|
||||
|
||||
private boolean allowStories = true;
|
||||
|
||||
private SignalServiceAccountManager accountManager;
|
||||
private GroupsV2Api groupsV2Api;
|
||||
private GroupsV2Operations groupsV2Operations;
|
||||
|
@ -72,6 +74,14 @@ public class SignalDependencies {
|
|||
public void resetAfterAddressChange() {
|
||||
this.messageSender = null;
|
||||
this.cipher = null;
|
||||
getSignalWebSocket().forceNewWebSockets();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method needs to be called before the first websocket is created
|
||||
*/
|
||||
public void setAllowStories(final boolean allowStories) {
|
||||
this.allowStories = allowStories;
|
||||
}
|
||||
|
||||
public ServiceEnvironmentConfig getServiceEnvironmentConfig() {
|
||||
|
@ -135,7 +145,7 @@ public class SignalDependencies {
|
|||
Optional.of(credentialsProvider),
|
||||
userAgent,
|
||||
healthMonitor,
|
||||
true);
|
||||
allowStories);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,7 +155,7 @@ public class SignalDependencies {
|
|||
Optional.empty(),
|
||||
userAgent,
|
||||
healthMonitor,
|
||||
true);
|
||||
allowStories);
|
||||
}
|
||||
};
|
||||
signalWebSocket = new SignalWebSocket(webSocketFactory);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package org.asamk.signal.manager.api;
|
||||
|
||||
public record ReceiveConfig(boolean ignoreAttachments, boolean sendReadReceipts) {}
|
||||
public record ReceiveConfig(boolean ignoreAttachments, boolean ignoreStories, boolean sendReadReceipts) {}
|
||||
|
|
|
@ -110,7 +110,6 @@ public class AccountHelper {
|
|||
// TODO check and update remote storage
|
||||
context.getUnidentifiedAccessHelper().rotateSenderCertificates();
|
||||
dependencies.resetAfterAddressChange();
|
||||
dependencies.getSignalWebSocket().forceNewWebSockets();
|
||||
context.getAccountFileUpdater().updateAccountIdentifiers(account.getNumber(), account.getAci());
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.asamk.signal.manager.storage.SignalAccount;
|
|||
import org.asamk.signal.manager.storage.messageCache.CachedMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.SignalWebSocket;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException;
|
||||
|
@ -35,7 +36,7 @@ public class ReceiveHelper {
|
|||
private final SignalDependencies dependencies;
|
||||
private final Context context;
|
||||
|
||||
private ReceiveConfig receiveConfig = new ReceiveConfig(false, false);
|
||||
private ReceiveConfig receiveConfig = new ReceiveConfig(false, false, false);
|
||||
private boolean needsToRetryFailedMessages = false;
|
||||
private boolean hasCaughtUpWithOldMessages = false;
|
||||
private boolean isWaitingForMessage = false;
|
||||
|
@ -51,6 +52,7 @@ public class ReceiveHelper {
|
|||
|
||||
public void setReceiveConfig(final ReceiveConfig receiveConfig) {
|
||||
this.receiveConfig = receiveConfig;
|
||||
dependencies.setAllowStories(!receiveConfig.ignoreStories());
|
||||
}
|
||||
|
||||
public void setNeedsToRetryFailedMessages(final boolean needsToRetryFailedMessages) {
|
||||
|
@ -104,25 +106,24 @@ public class ReceiveHelper {
|
|||
signalWebSocket.connect();
|
||||
|
||||
try {
|
||||
receiveMessagesInternal(timeout, returnOnTimeout, handler, queuedActions);
|
||||
receiveMessagesInternal(signalWebSocket, timeout, returnOnTimeout, handler, queuedActions);
|
||||
} finally {
|
||||
hasCaughtUpWithOldMessages = false;
|
||||
handleQueuedActions(queuedActions.keySet());
|
||||
queuedActions.clear();
|
||||
dependencies.getSignalWebSocket().disconnect();
|
||||
signalWebSocket.disconnect();
|
||||
webSocketStateDisposable.dispose();
|
||||
shouldStop = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void receiveMessagesInternal(
|
||||
final SignalWebSocket signalWebSocket,
|
||||
Duration timeout,
|
||||
boolean returnOnTimeout,
|
||||
Manager.ReceiveMessageHandler handler,
|
||||
final Map<HandleAction, HandleAction> queuedActions
|
||||
) throws IOException {
|
||||
final var signalWebSocket = dependencies.getSignalWebSocket();
|
||||
|
||||
var backOffCounter = 0;
|
||||
isWaitingForMessage = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue