X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/d27a12a6cfcf9afca362a8d359ee808b1507e0b3..276ecef3009baecb740f23d53ddaa81f487d57a2:/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 aeef7f15..f4489ea7 100644 --- a/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java +++ b/lib/src/main/java/org/asamk/signal/manager/SignalDependencies.java @@ -22,6 +22,7 @@ import org.whispersystems.signalservice.api.util.UptimeSleepTimer; import org.whispersystems.signalservice.api.websocket.WebSocketFactory; import org.whispersystems.signalservice.internal.websocket.WebSocketConnection; +import java.util.Collection; import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.function.Supplier; @@ -39,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; @@ -71,12 +74,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(), @@ -104,7 +119,7 @@ public class SignalDependencies { public GroupsV2Operations getGroupsV2Operations() { return getOrCreate(() -> groupsV2Operations, - () -> groupsV2Operations = capabilities.isGv2() + () -> groupsV2Operations = capabilities.getGv2() ? new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()), ServiceConfig.GROUP_MAX_SIZE) : null); @@ -112,7 +127,7 @@ public class SignalDependencies { private ClientZkOperations getClientZkOperations() { return getOrCreate(() -> clientZkOperations, - () -> clientZkOperations = capabilities.isGv2() + () -> clientZkOperations = capabilities.getGv2() ? ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()) : null); } @@ -133,7 +148,8 @@ public class SignalDependencies { serviceEnvironmentConfig.getSignalServiceConfiguration(), Optional.of(credentialsProvider), userAgent, - healthMonitor); + healthMonitor, + allowStories); } @Override @@ -142,7 +158,8 @@ public class SignalDependencies { serviceEnvironmentConfig.getSignalServiceConfiguration(), Optional.empty(), userAgent, - healthMonitor); + healthMonitor, + allowStories); } }; signalWebSocket = new SignalWebSocket(webSocketFactory); @@ -183,6 +200,17 @@ public class SignalDependencies { 10)); } + public Collection getFallbackKeyBackupServices() { + return serviceEnvironmentConfig.getFallbackKeyBackupConfigs() + .stream() + .map(config -> getAccountManager().getKeyBackupService(ServiceConfig.getIasKeyStore(), + config.getEnclaveName(), + config.getServiceId(), + config.getMrenclave(), + 10)) + .toList(); + } + public ProfileService getProfileService() { return getOrCreate(() -> profileService, () -> profileService = new ProfileService(getClientZkProfileOperations(),