Add missing check if client zk operations are null

Fixes #710
This commit is contained in:
AsamK 2021-09-09 18:58:45 +02:00
parent a17262d9ff
commit 1856e79a50

View file

@ -3,6 +3,7 @@ package org.asamk.signal.manager;
import org.asamk.signal.manager.config.ServiceConfig; import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig; import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.signal.libsignal.metadata.certificate.CertificateValidator; import org.signal.libsignal.metadata.certificate.CertificateValidator;
import org.signal.zkgroup.profiles.ClientZkProfileOperations;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.KeyBackupService; import org.whispersystems.signalservice.api.KeyBackupService;
import org.whispersystems.signalservice.api.SignalServiceAccountManager; import org.whispersystems.signalservice.api.SignalServiceAccountManager;
@ -93,6 +94,11 @@ public class SignalDependencies {
: null); : null);
} }
private ClientZkProfileOperations getClientZkProfileOperations() {
final var clientZkOperations = getClientZkOperations();
return clientZkOperations == null ? null : clientZkOperations.getProfileOperations();
}
public SignalWebSocket getSignalWebSocket() { public SignalWebSocket getSignalWebSocket() {
return getOrCreate(() -> signalWebSocket, () -> { return getOrCreate(() -> signalWebSocket, () -> {
final var timer = new UptimeSleepTimer(); final var timer = new UptimeSleepTimer();
@ -126,7 +132,7 @@ public class SignalDependencies {
() -> messageReceiver = new SignalServiceMessageReceiver(serviceEnvironmentConfig.getSignalServiceConfiguration(), () -> messageReceiver = new SignalServiceMessageReceiver(serviceEnvironmentConfig.getSignalServiceConfiguration(),
credentialsProvider, credentialsProvider,
userAgent, userAgent,
getClientZkOperations().getProfileOperations(), getClientZkProfileOperations(),
ServiceConfig.AUTOMATIC_NETWORK_RETRY)); ServiceConfig.AUTOMATIC_NETWORK_RETRY));
} }
@ -139,7 +145,7 @@ public class SignalDependencies {
userAgent, userAgent,
getSignalWebSocket(), getSignalWebSocket(),
Optional.absent(), Optional.absent(),
getClientZkOperations().getProfileOperations(), getClientZkProfileOperations(),
executor, executor,
ServiceConfig.MAX_ENVELOPE_SIZE, ServiceConfig.MAX_ENVELOPE_SIZE,
ServiceConfig.AUTOMATIC_NETWORK_RETRY)); ServiceConfig.AUTOMATIC_NETWORK_RETRY));
@ -156,7 +162,7 @@ public class SignalDependencies {
public ProfileService getProfileService() { public ProfileService getProfileService() {
return getOrCreate(() -> profileService, return getOrCreate(() -> profileService,
() -> profileService = new ProfileService(getClientZkOperations().getProfileOperations(), () -> profileService = new ProfileService(getClientZkProfileOperations(),
getMessageReceiver(), getMessageReceiver(),
getSignalWebSocket())); getSignalWebSocket()));
} }