X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/7e5aec6e15ac104a62a375754bf4d2d21f55ee3a..916d0e3cf1713d91c0d8c511c0f31986caad22b7:/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index dcc01d94..f76642c9 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.asamk.Signal; import org.asamk.signal.AttachmentInvalidException; import org.asamk.signal.GroupNotFoundException; -import org.asamk.signal.JsonStickerPack; import org.asamk.signal.NotAGroupMemberException; import org.asamk.signal.StickerPackInvalidException; import org.asamk.signal.TrustLevel; @@ -47,6 +46,7 @@ import org.signal.libsignal.metadata.SelfSendException; import org.signal.libsignal.metadata.certificate.InvalidCertificateException; import org.signal.zkgroup.InvalidInputException; import org.signal.zkgroup.VerificationFailedException; +import org.signal.zkgroup.profiles.ClientZkProfileOperations; import org.signal.zkgroup.profiles.ProfileKey; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKeyPair; @@ -75,6 +75,7 @@ import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; import org.whispersystems.signalservice.api.messages.SendMessageResult; import org.whispersystems.signalservice.api.messages.SignalServiceAttachment; import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer; +import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId; import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream; import org.whispersystems.signalservice.api.messages.SignalServiceContent; import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage; @@ -100,6 +101,7 @@ import org.whispersystems.signalservice.api.profiles.SignalServiceProfile; import org.whispersystems.signalservice.api.push.ContactTokenDetails; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions; +import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException; import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException; import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; import org.whispersystems.signalservice.api.util.InvalidNumberException; @@ -109,6 +111,7 @@ import org.whispersystems.signalservice.api.util.UptimeSleepTimer; import org.whispersystems.signalservice.api.util.UuidUtil; import org.whispersystems.signalservice.internal.push.SignalServiceProtos; import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException; +import org.whispersystems.signalservice.internal.push.VerifyAccountResponse; import org.whispersystems.signalservice.internal.util.Hex; import org.whispersystems.util.Base64; @@ -125,11 +128,13 @@ import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.Deque; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -139,6 +144,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -235,7 +241,7 @@ public class Manager implements Signal { if (JsonGroupStore.groupsWithLegacyAvatarId.size() > 0) { for (GroupInfo g : JsonGroupStore.groupsWithLegacyAvatarId) { File avatarFile = getGroupAvatarFile(g.groupId); - File attachmentFile = getAttachmentFile(g.getAvatarId()); + File attachmentFile = getAttachmentFile(new SignalServiceAttachmentRemoteId(g.getAvatarId())); if (!avatarFile.exists() && attachmentFile.exists()) { try { IOUtils.createPrivateDirectories(avatarsPath); @@ -431,8 +437,10 @@ public class Manager implements Signal { verificationCode = verificationCode.replace("-", ""); account.setSignalingKey(KeyUtils.createSignalingKey()); // TODO make unrestricted unidentified access configurable - UUID uuid = accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, BaseConfig.capabilities); + VerifyAccountResponse response = accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, BaseConfig.capabilities); + UUID uuid = UuidUtil.parseOrNull(response.getUuid()); + // TODO response.isStorageCapable() //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID))); account.setRegistered(true); account.setUuid(uuid); @@ -449,7 +457,7 @@ public class Manager implements Signal { throw new RuntimeException("Not implemented anymore, will be replaced with KBS"); } else { account.setRegistrationLockPin(null); - accountManager.removeV1Pin(); + accountManager.removeRegistrationLockV1(); } account.save(); } @@ -463,12 +471,17 @@ public class Manager implements Signal { } private SignalServiceMessageReceiver getMessageReceiver() { - return new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, account.getUuid(), account.getUsername(), account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer); + // TODO implement ZkGroup support + final ClientZkProfileOperations clientZkProfileOperations = null; + return new SignalServiceMessageReceiver(BaseConfig.serviceConfiguration, account.getUuid(), account.getUsername(), account.getPassword(), account.getDeviceId(), account.getSignalingKey(), BaseConfig.USER_AGENT, null, timer, clientZkProfileOperations); } private SignalServiceMessageSender getMessageSender() { + // TODO implement ZkGroup support + final ClientZkProfileOperations clientZkProfileOperations = null; + final boolean attachmentsV3 = false; return new SignalServiceMessageSender(BaseConfig.serviceConfiguration, account.getUuid(), account.getUsername(), account.getPassword(), - account.getDeviceId(), account.getSignalProtocolStore(), BaseConfig.USER_AGENT, account.isMultiDevice(), Optional.fromNullable(messagePipe), Optional.fromNullable(unidentifiedMessagePipe), Optional.absent()); + account.getDeviceId(), account.getSignalProtocolStore(), BaseConfig.USER_AGENT, account.isMultiDevice(), attachmentsV3, Optional.fromNullable(messagePipe), Optional.fromNullable(unidentifiedMessagePipe), Optional.absent(), clientZkProfileOperations); } private SignalServiceProfile getRecipientProfile(SignalServiceAddress address, Optional unidentifiedAccess) throws IOException { @@ -524,7 +537,7 @@ public class Manager implements Signal { } @Override - public void sendGroupMessage(String messageText, List attachments, + public long sendGroupMessage(String messageText, List attachments, byte[] groupId) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException { final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText); @@ -542,7 +555,7 @@ public class Manager implements Signal { messageBuilder.withExpiration(g.messageExpirationTime); - sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); + return sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress())); } public void sendGroupMessageReaction(String emoji, boolean remove, String targetAuthor, @@ -687,15 +700,15 @@ public class Manager implements Signal { } @Override - public void sendMessage(String message, List attachments, String recipient) + public long sendMessage(String message, List attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException { List recipients = new ArrayList<>(1); recipients.add(recipient); - sendMessage(message, attachments, recipients); + return sendMessage(message, attachments, recipients); } @Override - public void sendMessage(String messageText, List attachments, + public long sendMessage(String messageText, List attachments, List recipients) throws IOException, EncapsulatedExceptions, AttachmentInvalidException, InvalidNumberException { final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText); @@ -715,7 +728,7 @@ public class Manager implements Signal { messageBuilder.withAttachments(attachmentPointers); } - sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); + return sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); } public void sendMessageReaction(String emoji, boolean remove, String targetAuthor, @@ -732,7 +745,15 @@ public class Manager implements Signal { SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .asEndSessionMessage(); - sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients)); + final Collection signalServiceAddresses = getSignalServiceAddresses(recipients); + try { + sendMessageLegacy(messageBuilder, signalServiceAddresses); + } catch (Exception e) { + for (SignalServiceAddress address : signalServiceAddresses) { + handleEndSession(address); + } + throw e; + } } @Override @@ -1133,8 +1154,10 @@ public class Manager implements Signal { /** * This method throws an EncapsulatedExceptions exception instead of returning a list of SendMessageResult. */ - private void sendMessageLegacy(SignalServiceDataMessage.Builder messageBuilder, Collection recipients) + private long sendMessageLegacy(SignalServiceDataMessage.Builder messageBuilder, Collection recipients) throws EncapsulatedExceptions, IOException { + final long timestamp = System.currentTimeMillis(); + messageBuilder.withTimestamp(timestamp); List results = sendMessage(messageBuilder, recipients); List untrustedIdentities = new LinkedList<>(); @@ -1153,6 +1176,7 @@ public class Manager implements Signal { if (!untrustedIdentities.isEmpty() || !unregisteredUsers.isEmpty() || !networkExceptions.isEmpty()) { throw new EncapsulatedExceptions(untrustedIdentities, unregisteredUsers, networkExceptions); } + return timestamp; } private Collection getSignalServiceAddresses(Collection numbers) throws InvalidNumberException { @@ -1177,7 +1201,7 @@ public class Manager implements Signal { SignalServiceMessageSender messageSender = getMessageSender(); message = messageBuilder.build(); - if (message.getGroupInfo().isPresent()) { + if (message.getGroupContext().isPresent()) { try { final boolean isRecipientUpdate = false; List result = messageSender.sendMessage(new ArrayList<>(recipients), getAccessFor(recipients), isRecipientUpdate, message); @@ -1243,14 +1267,17 @@ public class Manager implements Signal { } } - private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, ProtocolInvalidMessageException, ProtocolDuplicateMessageException, ProtocolLegacyMessageException, ProtocolInvalidKeyIdException, InvalidMetadataVersionException, ProtocolInvalidVersionException, ProtocolNoSessionException, ProtocolInvalidKeyException, ProtocolUntrustedIdentityException, SelfSendException, UnsupportedDataMessageException { + private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, ProtocolInvalidMessageException, ProtocolDuplicateMessageException, ProtocolLegacyMessageException, ProtocolInvalidKeyIdException, InvalidMetadataVersionException, ProtocolInvalidVersionException, ProtocolNoSessionException, ProtocolInvalidKeyException, SelfSendException, UnsupportedDataMessageException, org.whispersystems.libsignal.UntrustedIdentityException { SignalServiceCipher cipher = new SignalServiceCipher(account.getSelfAddress(), account.getSignalProtocolStore(), Utils.getCertificateValidator()); try { return cipher.decrypt(envelope); } catch (ProtocolUntrustedIdentityException e) { - // TODO We don't get the new untrusted identity from ProtocolUntrustedIdentityException anymore ... we need to get it from somewhere else -// account.getSignalProtocolStore().saveIdentity(e.getSender(), e.getUntrustedIdentity(), TrustLevel.UNTRUSTED); - throw e; + if (e.getCause() instanceof org.whispersystems.libsignal.UntrustedIdentityException) { + org.whispersystems.libsignal.UntrustedIdentityException identityException = (org.whispersystems.libsignal.UntrustedIdentityException) e.getCause(); + account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(identityException.getName()), identityException.getUntrustedIdentity(), TrustLevel.UNTRUSTED); + throw identityException; + } + throw new AssertionError(e); } } @@ -1259,8 +1286,8 @@ public class Manager implements Signal { } private void handleSignalServiceDataMessage(SignalServiceDataMessage message, boolean isSync, SignalServiceAddress source, SignalServiceAddress destination, boolean ignoreAttachments) { - if (message.getGroupInfo().isPresent()) { - SignalServiceGroup groupInfo = message.getGroupInfo().get(); + if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) { + SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get(); GroupInfo group = account.getGroupStore().getGroup(groupInfo.getGroupId()); switch (groupInfo.getType()) { case UPDATE: @@ -1273,8 +1300,8 @@ public class Manager implements Signal { if (avatar.isPointer()) { try { retrieveGroupAvatarAttachment(avatar.asPointer(), group.groupId); - } catch (IOException | InvalidMessageException e) { - System.err.println("Failed to retrieve group avatar (" + avatar.asPointer().getId() + "): " + e.getMessage()); + } catch (IOException | InvalidMessageException | MissingConfigurationException e) { + System.err.println("Failed to retrieve group avatar (" + avatar.asPointer().getRemoteId() + "): " + e.getMessage()); } } } @@ -1284,7 +1311,10 @@ public class Manager implements Signal { } if (groupInfo.getMembers().isPresent()) { - group.addMembers(groupInfo.getMembers().get()); + group.addMembers(groupInfo.getMembers().get() + .stream() + .map(this::resolveSignalServiceAddress) + .collect(Collectors.toSet())); } account.getGroupStore().updateGroup(group); @@ -1299,13 +1329,7 @@ public class Manager implements Signal { } break; case QUIT: - if (group == null) { - try { - sendGroupInfoRequest(groupInfo.getGroupId(), source); - } catch (IOException | EncapsulatedExceptions e) { - e.printStackTrace(); - } - } else { + if (group != null) { group.removeMember(source); account.getGroupStore().updateGroup(group); } @@ -1323,12 +1347,13 @@ public class Manager implements Signal { break; } } + final SignalServiceAddress conversationPartnerAddress = isSync ? destination : source; if (message.isEndSession()) { - handleEndSession(isSync ? destination : source); + handleEndSession(conversationPartnerAddress); } if (message.isExpirationUpdate() || message.getBody().isPresent()) { - if (message.getGroupInfo().isPresent()) { - SignalServiceGroup groupInfo = message.getGroupInfo().get(); + if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) { + SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get(); GroupInfo group = account.getGroupStore().getGroup(groupInfo.getGroupId()); if (group == null) { group = new GroupInfo(groupInfo.getGroupId()); @@ -1338,9 +1363,9 @@ public class Manager implements Signal { account.getGroupStore().updateGroup(group); } } else { - ContactInfo contact = account.getContactStore().getContact(isSync ? destination : source); + ContactInfo contact = account.getContactStore().getContact(conversationPartnerAddress); if (contact == null) { - contact = new ContactInfo(isSync ? destination : source); + contact = new ContactInfo(conversationPartnerAddress); } if (contact.messageExpirationTime != message.getExpiresInSeconds()) { contact.messageExpirationTime = message.getExpiresInSeconds(); @@ -1353,8 +1378,8 @@ public class Manager implements Signal { if (attachment.isPointer()) { try { retrieveAttachment(attachment.asPointer()); - } catch (IOException | InvalidMessageException e) { - System.err.println("Failed to retrieve attachment (" + attachment.asPointer().getId() + "): " + e.getMessage()); + } catch (IOException | InvalidMessageException | MissingConfigurationException e) { + System.err.println("Failed to retrieve attachment (" + attachment.asPointer().getRemoteId() + "): " + e.getMessage()); } } } @@ -1386,8 +1411,8 @@ public class Manager implements Signal { SignalServiceAttachmentPointer attachment = preview.getImage().get().asPointer(); try { retrieveAttachment(attachment); - } catch (IOException | InvalidMessageException e) { - System.err.println("Failed to retrieve attachment (" + attachment.getId() + "): " + e.getMessage()); + } catch (IOException | InvalidMessageException | MissingConfigurationException e) { + System.err.println("Failed to retrieve attachment (" + attachment.getRemoteId() + "): " + e.getMessage()); } } } @@ -1463,7 +1488,8 @@ public class Manager implements Signal { envelope = messagePipe.read(timeout, unit, envelope1 -> { // store message on disk, before acknowledging receipt to the server try { - File cacheFile = getMessageCacheFile(envelope1.getSourceE164().get(), now, envelope1.getTimestamp()); + String source = envelope1.getSourceE164().isPresent() ? envelope1.getSourceE164().get() : ""; + File cacheFile = getMessageCacheFile(source, now, envelope1.getTimestamp()); Utils.storeEnvelope(envelope1, cacheFile); } catch (IOException e) { System.err.println("Failed to store encrypted message in disk cache, ignoring: " + e.getMessage()); @@ -1489,7 +1515,7 @@ public class Manager implements Signal { if (!isMessageBlocked(envelope, content)) { handler.handleMessage(envelope, content, exception); } - if (!(exception instanceof ProtocolUntrustedIdentityException)) { + if (!(exception instanceof org.whispersystems.libsignal.UntrustedIdentityException)) { File cacheFile = null; try { cacheFile = getMessageCacheFile(envelope.getSourceE164().get(), now, envelope.getTimestamp()); @@ -1525,8 +1551,8 @@ public class Manager implements Signal { if (content != null && content.getDataMessage().isPresent()) { SignalServiceDataMessage message = content.getDataMessage().get(); - if (message.getGroupInfo().isPresent()) { - SignalServiceGroup groupInfo = message.getGroupInfo().get(); + if (message.getGroupContext().isPresent() && message.getGroupContext().get().getGroupV1().isPresent()) { + SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get(); GroupInfo group = getGroup(groupInfo.getGroupId()); if (groupInfo.getType() == SignalServiceGroup.Type.DELIVER && group != null && group.blocked) { return true; @@ -1550,7 +1576,7 @@ public class Manager implements Signal { if (content.isNeedsReceipt()) { try { sendReceipt(sender, message.getTimestamp()); - } catch (IOException | UntrustedIdentityException e) { + } catch (IOException | UntrustedIdentityException | IllegalArgumentException e) { e.printStackTrace(); } } @@ -1569,21 +1595,21 @@ public class Manager implements Signal { if (rm.isContactsRequest()) { try { sendContacts(); - } catch (UntrustedIdentityException | IOException e) { + } catch (UntrustedIdentityException | IOException | IllegalArgumentException e) { e.printStackTrace(); } } if (rm.isGroupsRequest()) { try { sendGroups(); - } catch (UntrustedIdentityException | IOException e) { + } catch (UntrustedIdentityException | IOException | IllegalArgumentException e) { e.printStackTrace(); } } if (rm.isBlockedListRequest()) { try { sendBlockedList(); - } catch (UntrustedIdentityException | IOException e) { + } catch (UntrustedIdentityException | IOException | IllegalArgumentException e) { e.printStackTrace(); } } @@ -1604,7 +1630,10 @@ public class Manager implements Signal { if (g.getName().isPresent()) { syncGroup.name = g.getName().get(); } - syncGroup.addMembers(g.getMembers()); + syncGroup.addMembers(g.getMembers() + .stream() + .map(this::resolveSignalServiceAddress) + .collect(Collectors.toSet())); if (!g.isActive()) { syncGroup.removeMember(account.getSelfAddress()); } else { @@ -1639,7 +1668,7 @@ public class Manager implements Signal { if (syncMessage.getBlockedList().isPresent()) { final BlockedListMessage blockedListMessage = syncMessage.getBlockedList().get(); for (SignalServiceAddress address : blockedListMessage.getAddresses()) { - setContactBlocked(address, true); + setContactBlocked(resolveSignalServiceAddress(address), true); } for (byte[] groupId : blockedListMessage.getGroupIds()) { try { @@ -1664,9 +1693,10 @@ public class Manager implements Signal { if (c.getAddress().matches(account.getSelfAddress()) && c.getProfileKey().isPresent()) { account.setProfileKey(c.getProfileKey().get()); } - ContactInfo contact = account.getContactStore().getContact(c.getAddress()); + final SignalServiceAddress address = resolveSignalServiceAddress(c.getAddress()); + ContactInfo contact = account.getContactStore().getContact(address); if (contact == null) { - contact = new ContactInfo(c.getAddress()); + contact = new ContactInfo(address); } if (c.getName().isPresent()) { contact.name = c.getName().get(); @@ -1708,7 +1738,7 @@ public class Manager implements Signal { } if (syncMessage.getVerified().isPresent()) { final VerifiedMessage verifiedMessage = syncMessage.getVerified().get(); - account.getSignalProtocolStore().setIdentityTrustLevel(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified())); + account.getSignalProtocolStore().setIdentityTrustLevel(resolveSignalServiceAddress(verifiedMessage.getDestination()), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified())); } if (syncMessage.getConfiguration().isPresent()) { // TODO @@ -1721,7 +1751,7 @@ public class Manager implements Signal { return new File(avatarsPath, "contact-" + number); } - private File retrieveContactAvatarAttachment(SignalServiceAttachment attachment, String number) throws IOException, InvalidMessageException { + private File retrieveContactAvatarAttachment(SignalServiceAttachment attachment, String number) throws IOException, InvalidMessageException, MissingConfigurationException { IOUtils.createPrivateDirectories(avatarsPath); if (attachment.isPointer()) { SignalServiceAttachmentPointer pointer = attachment.asPointer(); @@ -1736,7 +1766,7 @@ public class Manager implements Signal { return new File(avatarsPath, "group-" + Base64.encodeBytes(groupId).replace("/", "_")); } - private File retrieveGroupAvatarAttachment(SignalServiceAttachment attachment, byte[] groupId) throws IOException, InvalidMessageException { + private File retrieveGroupAvatarAttachment(SignalServiceAttachment attachment, byte[] groupId) throws IOException, InvalidMessageException, MissingConfigurationException { IOUtils.createPrivateDirectories(avatarsPath); if (attachment.isPointer()) { SignalServiceAttachmentPointer pointer = attachment.asPointer(); @@ -1747,16 +1777,16 @@ public class Manager implements Signal { } } - public File getAttachmentFile(long attachmentId) { - return new File(attachmentsPath, attachmentId + ""); + public File getAttachmentFile(SignalServiceAttachmentRemoteId attachmentId) { + return new File(attachmentsPath, attachmentId.toString()); } - private File retrieveAttachment(SignalServiceAttachmentPointer pointer) throws IOException, InvalidMessageException { + private File retrieveAttachment(SignalServiceAttachmentPointer pointer) throws IOException, InvalidMessageException, MissingConfigurationException { IOUtils.createPrivateDirectories(attachmentsPath); - return retrieveAttachment(pointer, getAttachmentFile(pointer.getId()), true); + return retrieveAttachment(pointer, getAttachmentFile(pointer.getRemoteId()), true); } - private File retrieveAttachment(SignalServiceAttachmentPointer pointer, File outputFile, boolean storePreview) throws IOException, InvalidMessageException { + private File retrieveAttachment(SignalServiceAttachmentPointer pointer, File outputFile, boolean storePreview) throws IOException, InvalidMessageException, MissingConfigurationException { if (storePreview && pointer.getPreview().isPresent()) { File previewFile = new File(outputFile + ".preview"); try (OutputStream output = new FileOutputStream(previewFile)) { @@ -1793,7 +1823,7 @@ public class Manager implements Signal { return outputFile; } - private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException { + private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException, MissingConfigurationException { final SignalServiceMessageReceiver messageReceiver = getMessageReceiver(); return messageReceiver.retrieveAttachment(pointer, tmpFile, BaseConfig.MAX_ATTACHMENT_SIZE); } @@ -1803,6 +1833,11 @@ public class Manager implements Signal { return false; } + @Override + public String getObjectPath() { + return null; + } + private void sendGroups() throws IOException, UntrustedIdentityException { File groupsFile = IOUtils.createTempFile(); @@ -2027,15 +2062,16 @@ public class Manager implements Signal { public SignalServiceAddress resolveSignalServiceAddress(String identifier) { SignalServiceAddress address = Util.getSignalServiceAddressFromIdentifier(identifier); + + return resolveSignalServiceAddress(address); + } + + public SignalServiceAddress resolveSignalServiceAddress(SignalServiceAddress address) { if (address.matches(account.getSelfAddress())) { return account.getSelfAddress(); } - ContactInfo contactInfo = account.getContactStore().getContact(address); - if (contactInfo == null) { - return address; - } - return contactInfo.getAddress(); + return account.getRecipientStore().resolveServiceAddress(address); } public interface ReceiveMessageHandler {