X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/1dd22132ffd15cc25fffa62aa765af979c7ae347..d2251ccd14081b80a1c7bcc906ad866502ff921b:/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java diff --git a/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java b/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java index 6450f1f8..7a8ecc4b 100644 --- a/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java +++ b/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java @@ -27,8 +27,6 @@ import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.function.Supplier; -import static org.asamk.signal.manager.config.ServiceConfig.capabilities; - public class SignalDependencies { private final Object LOCK = new Object(); @@ -40,6 +38,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,12 +72,24 @@ 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() { return serviceEnvironmentConfig; } + public SignalSessionLock getSessionLock() { + return sessionLock; + } + public SignalServiceAccountManager getAccountManager() { return getOrCreate(() -> accountManager, () -> accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(), @@ -105,17 +117,13 @@ public class SignalDependencies { public GroupsV2Operations getGroupsV2Operations() { return getOrCreate(() -> groupsV2Operations, - () -> groupsV2Operations = capabilities.isGv2() - ? new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()), - ServiceConfig.GROUP_MAX_SIZE) - : null); + () -> groupsV2Operations = new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()), + ServiceConfig.GROUP_MAX_SIZE)); } private ClientZkOperations getClientZkOperations() { return getOrCreate(() -> clientZkOperations, - () -> clientZkOperations = capabilities.isGv2() - ? ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()) - : null); + () -> clientZkOperations = ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration())); } private ClientZkProfileOperations getClientZkProfileOperations() { @@ -135,7 +143,7 @@ public class SignalDependencies { Optional.of(credentialsProvider), userAgent, healthMonitor, - true); + allowStories); } @Override @@ -145,7 +153,7 @@ public class SignalDependencies { Optional.empty(), userAgent, healthMonitor, - true); + allowStories); } }; signalWebSocket = new SignalWebSocket(webSocketFactory);