From f1e5fc6c0ba85ac95055b760d31d8fe0a1b27ab6 Mon Sep 17 00:00:00 2001 From: AsamK Date: Thu, 31 Dec 2020 16:14:30 +0100 Subject: [PATCH] Request profiles without uuid if libzkgroup is not available Fixes #397 --- .../signal/manager/helper/ProfileHelper.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java b/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java index c81e2ff7..60c47d8b 100644 --- a/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java +++ b/src/main/java/org/asamk/signal/manager/helper/ProfileHelper.java @@ -95,7 +95,17 @@ public final class ProfileHelper { ? unidentifiedPipe : messagePipeProvider.getMessagePipe(false); if (pipe != null) { - return pipe.getProfile(address, profileKey, unidentifiedAccess, requestType); + try { + 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!"); @@ -106,9 +116,18 @@ public final class ProfileHelper { Optional profileKey, Optional unidentifiedAccess, SignalServiceProfile.RequestType requestType - ) { + ) throws NotFoundException { SignalServiceMessageReceiver receiver = messageReceiverProvider.getMessageReceiver(); - return receiver.retrieveProfile(address, profileKey, unidentifiedAccess, requestType); + try { + 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 getUnidentifiedAccess(SignalServiceAddress recipient) {