X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/fc8b6d0fcbedd6a4c9ae394a0640e79690e28337..8867a7b9eeb3353d059613544899b262f4f47579:/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 7eb65af3..e59c7f86 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -111,7 +111,7 @@ public class DbusSignalImpl implements Signal { @Override public void subscribeReceive() { if (dbusMessageHandler == null) { - dbusMessageHandler = new DbusReceiveMessageHandler(m, connection, objectPath); + dbusMessageHandler = new DbusReceiveMessageHandler(connection, objectPath); m.addReceiveHandler(dbusMessageHandler); } subscriberCount++; @@ -199,7 +199,7 @@ public class DbusSignalImpl implements Signal { @Override public long sendMessage(final String message, final List attachments, final List recipients) { try { - final var results = m.sendMessage(new Message(message, attachments, List.of()), + final var results = m.sendMessage(new Message(message, attachments, List.of(), Optional.empty()), getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream() .map(RecipientIdentifier.class::cast) .collect(Collectors.toSet())); @@ -364,7 +364,7 @@ public class DbusSignalImpl implements Signal { final String message, final List attachments ) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity { try { - final var results = m.sendMessage(new Message(message, attachments, List.of()), + final var results = m.sendMessage(new Message(message, attachments, List.of(), Optional.empty()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE)); checkSendMessageResults(results.timestamp(), results.results()); return results.timestamp(); @@ -387,10 +387,28 @@ 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 { - var results = m.sendMessage(new Message(message, attachments, List.of()), + var results = m.sendMessage(new Message(message, attachments, List.of(), Optional.empty()), Set.of(new RecipientIdentifier.Group(getGroupId(groupId)))); checkSendMessageResults(results.timestamp(), results.results()); return results.timestamp(); @@ -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 {