X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/e83f43065ecd7922de75ea4f9262d6f2770369b2..06e93b84da2718c31111e820cd35a3354f22bae2:/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 0baacecb..0c59429c 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -26,7 +26,7 @@ import org.asamk.signal.manager.groups.LastGroupAdminException; import org.asamk.signal.manager.groups.NotAGroupMemberException; import org.asamk.signal.manager.storage.recipients.Profile; import org.asamk.signal.manager.storage.recipients.RecipientAddress; -import org.asamk.signal.util.ErrorUtils; +import org.asamk.signal.util.SendMessageResultUtils; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.exceptions.DBusException; @@ -387,6 +387,24 @@ public class DbusSignalImpl implements Signal { } } + @Override + public void deleteRecipient(final String recipient) throws Error.Failure { + try { + m.deleteRecipient(getSingleRecipientIdentifier(recipient, m.getSelfNumber())); + } catch (IOException e) { + throw new Error.Failure("Recipient not found"); + } + } + + @Override + public void deleteContact(final String recipient) throws Error.Failure { + try { + m.deleteContact(getSingleRecipientIdentifier(recipient, m.getSelfNumber())); + } catch (IOException e) { + throw new Error.Failure("Contact not found"); + } + } + @Override public long sendGroupMessage(final String message, final List attachments, final byte[] groupId) { try { @@ -661,7 +679,7 @@ public class DbusSignalImpl implements Signal { public List listNumbers() { return Stream.concat(m.getIdentities().stream().map(Identity::recipient), m.getContacts().stream().map(Pair::first)) - .map(a -> a.getNumber().orElse(null)) + .map(a -> a.number().orElse(null)) .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); @@ -680,7 +698,7 @@ public class DbusSignalImpl implements Signal { // Try profiles if no contact name was found for (var identity : m.getIdentities()) { final var address = identity.recipient(); - var number = address.getNumber().orElse(null); + var number = address.number().orElse(null); if (number != null) { Profile profile = null; try { @@ -763,7 +781,7 @@ public class DbusSignalImpl implements Signal { } private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException { - var error = ErrorUtils.getErrorMessageFromSendMessageResult(result); + var error = SendMessageResultUtils.getErrorMessageFromSendMessageResult(result); if (error == null) { return; @@ -787,7 +805,7 @@ public class DbusSignalImpl implements Signal { return; } - var errors = ErrorUtils.getErrorMessagesFromSendMessageResults(results); + var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results); if (errors.size() == 0) { return; } @@ -810,7 +828,7 @@ public class DbusSignalImpl implements Signal { return; } - var errors = ErrorUtils.getErrorMessagesFromSendMessageResults(results); + var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results); if (errors.size() == 0) { return; }