private final ExecutorService executor;
private final SignalSessionLock sessionLock;
+ private boolean allowStories = true;
+
private SignalServiceAccountManager accountManager;
private GroupsV2Api groupsV2Api;
private GroupsV2Operations groupsV2Operations;
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() {
Optional.of(credentialsProvider),
userAgent,
healthMonitor,
- true);
+ allowStories);
}
@Override
Optional.empty(),
userAgent,
healthMonitor,
- true);
+ allowStories);
}
};
signalWebSocket = new SignalWebSocket(webSocketFactory);
package org.asamk.signal.manager.api;
-public record ReceiveConfig(boolean ignoreAttachments, boolean sendReadReceipts) {}
+public record ReceiveConfig(boolean ignoreAttachments, boolean ignoreStories, boolean sendReadReceipts) {}
// TODO check and update remote storage
context.getUnidentifiedAccessHelper().rotateSenderCertificates();
dependencies.resetAfterAddressChange();
- dependencies.getSignalWebSocket().forceNewWebSockets();
context.getAccountFileUpdater().updateAccountIdentifiers(account.getNumber(), account.getAci());
}
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;
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;
public void setReceiveConfig(final ReceiveConfig receiveConfig) {
this.receiveConfig = receiveConfig;
+ dependencies.setAllowStories(!receiveConfig.ignoreStories());
}
public void setNeedsToRetryFailedMessages(final boolean needsToRetryFailedMessages) {
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;
*-t* TIMEOUT, *--timeout* TIMEOUT::
Number of seconds to wait for new messages (negative values disable timeout).
Default is 5 seconds.
+
*--ignore-attachments*::
Don’t download attachments of received messages.
+*--ignore-stories*::
+Don’t receive story messages from the server.
+
+
*--send-read-receipts*::
Send read receipts for all incoming data messages (in addition to the default delivery receipts)
*--ignore-attachments*::
Don’t download attachments of received messages.
+*--ignore-stories*::
+Don’t receive story messages from the server.
+
*--send-read-receipts*::
Send read receipts for all incoming data messages (in addition to the default delivery receipts)
subparser.addArgument("--ignore-attachments")
.help("Don’t download attachments of received messages.")
.action(Arguments.storeTrue());
+ subparser.addArgument("--ignore-stories")
+ .help("Don’t receive story messages from the server.")
+ .action(Arguments.storeTrue());
subparser.addArgument("--send-read-receipts")
.help("Send read receipts for all incoming data messages (in addition to the default delivery receipts)")
.action(Arguments.storeTrue());
final var noReceiveStdOut = Boolean.TRUE.equals(ns.getBoolean("no-receive-stdout"));
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
- final boolean sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, sendReadReceipts));
+ m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts));
addDefaultReceiveHandler(m, noReceiveStdOut ? null : outputWriter, receiveMode != ReceiveMode.ON_START);
final Channel inheritedChannel;
final var noReceiveStdOut = Boolean.TRUE.equals(ns.getBoolean("no-receive-stdout"));
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
- final boolean sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- final var receiveConfig = new ReceiveConfig(ignoreAttachments, sendReadReceipts);
+ final var receiveConfig = new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts);
c.getManagers().forEach(m -> {
m.setReceiveConfig(receiveConfig);
addDefaultReceiveHandler(m, noReceiveStdOut ? null : outputWriter, receiveMode != ReceiveMode.ON_START);
subparser.addArgument("--ignore-attachments")
.help("Don’t download attachments of received messages.")
.action(Arguments.storeTrue());
+ subparser.addArgument("--ignore-stories")
+ .help("Don’t receive story messages from the server.")
+ .action(Arguments.storeTrue());
subparser.addArgument("--send-read-receipts")
.help("Send read receipts for all incoming data messages (in addition to the default delivery receipts)")
.action(Arguments.storeTrue());
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
- final boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
- final boolean sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, sendReadReceipts));
+ final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
+ m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts));
final var jsonOutputWriter = (JsonWriter) outputWriter;
final Supplier<String> lineSupplier = IOUtils.getLineSupplier(new InputStreamReader(System.in,
subparser.addArgument("--ignore-attachments")
.help("Don’t download attachments of received messages.")
.action(Arguments.storeTrue());
+ subparser.addArgument("--ignore-stories")
+ .help("Don’t receive story messages from the server.")
+ .action(Arguments.storeTrue());
subparser.addArgument("--send-read-receipts")
.help("Send read receipts for all incoming data messages (in addition to the default delivery receipts)")
.action(Arguments.storeTrue());
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
- double timeout = ns.getDouble("timeout");
- boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
- boolean sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, sendReadReceipts));
+ final var timeout = ns.getDouble("timeout");
+ final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
+ m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts));
try {
final var handler = outputWriter instanceof JsonWriter ? new JsonReceiveMessageHandler(m,
(JsonWriter) outputWriter) : new ReceiveMessageHandler(m, (PlainTextWriter) outputWriter);