X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/81a11dc9776672e3468ee9a8eed556889fb2e070..fc8b6d0fcbedd6a4c9ae394a0640e79690e28337:/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 c9099c0b..7eb65af3 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -2,12 +2,10 @@ package org.asamk.signal.dbus; import org.asamk.Signal; import org.asamk.signal.BaseConfig; -import org.asamk.signal.DbusReceiveMessageHandler; import org.asamk.signal.manager.AttachmentInvalidException; import org.asamk.signal.manager.Manager; 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; @@ -129,9 +127,7 @@ public class DbusSignalImpl implements Signal { } @Override - public void submitRateLimitChallenge(String challenge, String captchaString) { - final var captcha = captchaString == null ? null : captchaString.replace("signalcaptcha://", ""); - + public void submitRateLimitChallenge(String challenge, String captcha) { try { m.submitRateLimitRecaptchaChallenge(challenge, captcha); } catch (IOException e) { @@ -140,6 +136,24 @@ public class DbusSignalImpl implements Signal { } + @Override + public void unregister() throws Error.Failure { + try { + m.unregister(); + } catch (IOException e) { + throw new Error.Failure("Failed to unregister: " + e.getMessage()); + } + } + + @Override + public void deleteAccount() throws Error.Failure { + try { + m.deleteAccount(); + } catch (IOException e) { + throw new Error.Failure("Failed to delete account: " + e.getMessage()); + } + } + @Override public void addDevice(String uri) { try { @@ -185,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), + final var results = m.sendMessage(new Message(message, attachments, List.of()), getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream() .map(RecipientIdentifier.class::cast) .collect(Collectors.toSet())); @@ -289,16 +303,15 @@ public class DbusSignalImpl implements Signal { try { var recipients = new ArrayList(1); recipients.add(recipient); - m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START, + final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START, getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream() .map(RecipientIdentifier.class::cast) .collect(Collectors.toSet())); + checkSendMessageResults(results.timestamp(), results.results()); } catch (IOException e) { throw new Error.Failure(e.getMessage()); } catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) { throw new Error.GroupNotFound(e.getMessage()); - } catch (UntrustedIdentityException e) { - throw new Error.UntrustedIdentity(e.getMessage()); } } @@ -307,11 +320,11 @@ public class DbusSignalImpl implements Signal { final String recipient, final List messageIds ) throws Error.Failure, Error.UntrustedIdentity { try { - m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds); + final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), + messageIds); + checkSendMessageResults(results.timestamp(), results.results()); } catch (IOException e) { throw new Error.Failure(e.getMessage()); - } catch (UntrustedIdentityException e) { - throw new Error.UntrustedIdentity(e.getMessage()); } } @@ -320,11 +333,11 @@ public class DbusSignalImpl implements Signal { final String recipient, final List messageIds ) throws Error.Failure, Error.UntrustedIdentity { try { - m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds); + final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), + messageIds); + checkSendMessageResults(results.timestamp(), results.results()); } catch (IOException e) { throw new Error.Failure(e.getMessage()); - } catch (UntrustedIdentityException e) { - throw new Error.UntrustedIdentity(e.getMessage()); } } @@ -351,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), + final var results = m.sendMessage(new Message(message, attachments, List.of()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE)); checkSendMessageResults(results.timestamp(), results.results()); return results.timestamp(); @@ -377,7 +390,7 @@ public class DbusSignalImpl implements Signal { @Override public long sendGroupMessage(final String message, final List attachments, final byte[] groupId) { try { - var results = m.sendMessage(new Message(message, attachments), + var results = m.sendMessage(new Message(message, attachments, List.of()), Set.of(new RecipientIdentifier.Group(getGroupId(groupId)))); checkSendMessageResults(results.timestamp(), results.results()); return results.timestamp();