X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/ce7aa580b6f0580cdcf7fd68fcc8efba737d21ed..782f96b580b2e659539027d7bf4be159c8622029:/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java index 69e36623..28187771 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -9,7 +9,10 @@ import org.asamk.signal.manager.NotMasterDeviceException; import org.asamk.signal.manager.StickerPackInvalidException; import org.asamk.signal.manager.UntrustedIdentityException; import org.asamk.signal.manager.api.Identity; +import org.asamk.signal.manager.api.InactiveGroupLinkException; +import org.asamk.signal.manager.api.InvalidDeviceLinkException; import org.asamk.signal.manager.api.Message; +import org.asamk.signal.manager.api.Pair; import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.TypingAction; import org.asamk.signal.manager.api.UpdateGroup; @@ -29,12 +32,7 @@ import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.freedesktop.dbus.types.Variant; -import org.whispersystems.libsignal.InvalidKeyException; -import org.whispersystems.libsignal.util.Pair; -import org.whispersystems.libsignal.util.guava.Optional; -import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException; import org.whispersystems.signalservice.api.messages.SendMessageResult; -import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException; @@ -50,6 +48,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -107,7 +106,7 @@ public class DbusSignalImpl implements Signal { public void addDevice(String uri) { try { m.addDeviceLink(new URI(uri)); - } catch (IOException | InvalidKeyException e) { + } catch (IOException | InvalidDeviceLinkException e) { throw new Error.Failure(e.getClass().getSimpleName() + " Add device link failed. " + e.getMessage()); } catch (URISyntaxException e) { throw new Error.InvalidUri(e.getClass().getSimpleName() @@ -158,7 +157,7 @@ public class DbusSignalImpl implements Signal { } catch (AttachmentInvalidException e) { throw new Error.AttachmentInvalid(e.getMessage()); } catch (IOException e) { - throw new Error.Failure(e.getMessage()); + throw new Error.Failure(e); } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) { throw new Error.GroupNotFound(e.getMessage()); } @@ -278,6 +277,19 @@ public class DbusSignalImpl implements Signal { } } + @Override + public void sendViewedReceipt( + final String recipient, final List messageIds + ) throws Error.Failure, Error.UntrustedIdentity { + try { + m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds); + } catch (IOException e) { + throw new Error.Failure(e.getMessage()); + } catch (UntrustedIdentityException e) { + throw new Error.UntrustedIdentity(e.getMessage()); + } + } + @Override public void sendContacts() { try { @@ -377,7 +389,7 @@ public class DbusSignalImpl implements Signal { m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name); } catch (NotMasterDeviceException e) { throw new Error.Failure("This command doesn't work on linked devices."); - } catch (UnregisteredUserException e) { + } catch (IOException e) { throw new Error.Failure("Contact is not registered."); } } @@ -548,7 +560,7 @@ public class DbusSignalImpl implements Signal { aboutEmoji = nullIfEmpty(aboutEmoji); avatarPath = nullIfEmpty(avatarPath); Optional avatarFile = removeAvatar - ? Optional.absent() + ? Optional.empty() : avatarPath == null ? null : Optional.of(new File(avatarPath)); m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile); } catch (IOException e) { @@ -570,7 +582,7 @@ public class DbusSignalImpl implements Signal { @Override public void removePin() { try { - m.setRegistrationLockPin(Optional.absent()); + m.setRegistrationLockPin(Optional.empty()); } catch (UnauthenticatedResponseException e) { throw new Error.Failure("Remove pin failed with unauthenticated response: " + e.getMessage()); } catch (IOException e) { @@ -626,7 +638,7 @@ public class DbusSignalImpl implements Signal { Profile profile = null; try { profile = m.getRecipientProfile(RecipientIdentifier.Single.fromAddress(address)); - } catch (UnregisteredUserException ignored) { + } catch (IOException ignored) { } if (profile != null && profile.getDisplayName().equals(name)) { numbers.add(number); @@ -657,7 +669,7 @@ public class DbusSignalImpl implements Signal { } final var result = m.joinGroup(linkUrl); return result.first().serialize(); - } catch (GroupInviteLinkUrl.InvalidGroupLinkException | GroupLinkNotActiveException e) { + } catch (GroupInviteLinkUrl.InvalidGroupLinkException | InactiveGroupLinkException e) { throw new Error.Failure("Group link is invalid: " + e.getMessage()); } catch (GroupInviteLinkUrl.UnknownGroupLinkVersionException e) { throw new Error.Failure("Group link was created with an incompatible version: " + e.getMessage());