Request profiles without uuid if libzkgroup is not available

Fixes #397
This commit is contained in:
AsamK 2020-12-31 16:14:30 +01:00
parent 425626ef94
commit f1e5fc6c0b

View file

@ -95,7 +95,17 @@ public final class ProfileHelper {
? unidentifiedPipe ? unidentifiedPipe
: messagePipeProvider.getMessagePipe(false); : messagePipeProvider.getMessagePipe(false);
if (pipe != null) { if (pipe != null) {
try {
return pipe.getProfile(address, profileKey, unidentifiedAccess, requestType); return pipe.getProfile(address, profileKey, unidentifiedAccess, requestType);
} catch (NoClassDefFoundError e) {
// Native zkgroup lib not available for ProfileKey
if (!address.getNumber().isPresent()) {
throw new NotFoundException("Can't request profile without number");
}
SignalServiceAddress addressWithoutUuid = new SignalServiceAddress(Optional.absent(),
address.getNumber());
return pipe.getProfile(addressWithoutUuid, profileKey, unidentifiedAccess, requestType);
}
} }
throw new IOException("No pipe available!"); throw new IOException("No pipe available!");
@ -106,9 +116,18 @@ public final class ProfileHelper {
Optional<ProfileKey> profileKey, Optional<ProfileKey> profileKey,
Optional<UnidentifiedAccess> unidentifiedAccess, Optional<UnidentifiedAccess> unidentifiedAccess,
SignalServiceProfile.RequestType requestType SignalServiceProfile.RequestType requestType
) { ) throws NotFoundException {
SignalServiceMessageReceiver receiver = messageReceiverProvider.getMessageReceiver(); SignalServiceMessageReceiver receiver = messageReceiverProvider.getMessageReceiver();
try {
return receiver.retrieveProfile(address, profileKey, unidentifiedAccess, requestType); return receiver.retrieveProfile(address, profileKey, unidentifiedAccess, requestType);
} catch (NoClassDefFoundError e) {
// Native zkgroup lib not available for ProfileKey
if (!address.getNumber().isPresent()) {
throw new NotFoundException("Can't request profile without number");
}
SignalServiceAddress addressWithoutUuid = new SignalServiceAddress(Optional.absent(), address.getNumber());
return receiver.retrieveProfile(addressWithoutUuid, profileKey, unidentifiedAccess, requestType);
}
} }
private Optional<UnidentifiedAccess> getUnidentifiedAccess(SignalServiceAddress recipient) { private Optional<UnidentifiedAccess> getUnidentifiedAccess(SignalServiceAddress recipient) {