X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/280d8d7f10e7d6e6068545c4d5fce0bbbb96a2ea..47b6fe7dbe4f174909cabcdd0e0526a207950816:/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java diff --git a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java index 386e6fbe..3e463edf 100644 --- a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java @@ -27,7 +27,9 @@ import org.asamk.signal.manager.api.InvalidStickerException; import org.asamk.signal.manager.api.Message; import org.asamk.signal.manager.api.NotPrimaryDeviceException; import org.asamk.signal.manager.api.Pair; +import org.asamk.signal.manager.api.PendingAdminApprovalException; import org.asamk.signal.manager.api.ReceiveConfig; +import org.asamk.signal.manager.api.Recipient; import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.SendGroupMessageResults; import org.asamk.signal.manager.api.SendMessageResult; @@ -53,7 +55,6 @@ import org.asamk.signal.manager.storage.SignalAccount; import org.asamk.signal.manager.storage.groups.GroupInfo; import org.asamk.signal.manager.storage.identities.IdentityInfo; import org.asamk.signal.manager.storage.recipients.Profile; -import org.asamk.signal.manager.storage.recipients.Recipient; import org.asamk.signal.manager.storage.recipients.RecipientId; import org.asamk.signal.manager.storage.stickerPacks.JsonStickerPack; import org.asamk.signal.manager.storage.stickerPacks.StickerPackStore; @@ -216,13 +217,14 @@ class ManagerImpl implements Manager { return numbers.stream().collect(Collectors.toMap(n -> n, n -> { final var number = canonicalizedNumbers.get(n); - final var aci = registeredUsers.get(number); - final var profile = aci == null + final var user = registeredUsers.get(number); + final var serviceId = user == null ? null : user.getServiceId(); + final var profile = serviceId == null ? null : context.getProfileHelper() - .getRecipientProfile(account.getRecipientResolver().resolveRecipient(aci)); + .getRecipientProfile(account.getRecipientResolver().resolveRecipient(serviceId)); return new UserStatus(number.isEmpty() ? null : number, - aci == null ? null : aci.uuid(), + serviceId == null ? null : serviceId.uuid(), profile != null && profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED); })); @@ -431,7 +433,7 @@ class ManagerImpl implements Manager { @Override public Pair joinGroup( GroupInviteLinkUrl inviteLinkUrl - ) throws IOException, InactiveGroupLinkException { + ) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException { return context.getGroupHelper().joinGroup(inviteLinkUrl); } @@ -545,7 +547,7 @@ class ManagerImpl implements Manager { final var selfProfile = context.getProfileHelper().getSelfProfile(); if (selfProfile == null || selfProfile.getDisplayName().isEmpty()) { logger.warn( - "No profile name set. When sending a message it's recommended to set a profile name wit the updateProfile command. This may become mandatory in the future."); + "No profile name set. When sending a message it's recommended to set a profile name with the updateProfile command. This may become mandatory in the future."); } final var messageBuilder = SignalServiceDataMessage.newBuilder(); applyMessage(messageBuilder, message); @@ -706,13 +708,13 @@ class ManagerImpl implements Manager { @Override public void deleteRecipient(final RecipientIdentifier.Single recipient) { - account.removeRecipient(account.getRecipientResolver().resolveRecipient(recipient.toPartialRecipientAddress())); + account.removeRecipient(account.getRecipientResolver().resolveRecipient(recipient.getIdentifier())); } @Override public void deleteContact(final RecipientIdentifier.Single recipient) { account.getContactStore() - .deleteContact(account.getRecipientResolver().resolveRecipient(recipient.toPartialRecipientAddress())); + .deleteContact(account.getRecipientResolver().resolveRecipient(recipient.getIdentifier())); } @Override @@ -1004,7 +1006,16 @@ class ManagerImpl implements Manager { } // refresh profiles of explicitly given recipients context.getProfileHelper().refreshRecipientProfiles(recipientIds); - return account.getRecipientStore().getRecipients(onlyContacts, blocked, recipientIds, name); + return account.getRecipientStore() + .getRecipients(onlyContacts, blocked, recipientIds, name) + .stream() + .map(s -> new Recipient(s.getRecipientId(), + s.getAddress().toApiRecipientAddress(), + s.getContact(), + s.getProfileKey(), + s.getExpiringProfileKeyCredential(), + s.getProfile())) + .toList(); } @Override @@ -1048,7 +1059,7 @@ class ManagerImpl implements Manager { .resolveRecipientAddress(account.getRecipientResolver().resolveRecipient(identityInfo.getServiceId())); final var scannableFingerprint = context.getIdentityHelper() .computeSafetyNumberForScanning(identityInfo.getServiceId(), identityInfo.getIdentityKey()); - return new Identity(address, + return new Identity(address.toApiRecipientAddress(), identityInfo.getIdentityKey(), context.getIdentityHelper() .computeSafetyNumber(identityInfo.getServiceId(), identityInfo.getIdentityKey()),