X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/a17262d9ff7379c4f1590a3669af52e7237144bb..2ab42ca5471e8fc1e1a31cde954e19564178f114:/src/main/java/org/asamk/signal/util/ErrorUtils.java diff --git a/src/main/java/org/asamk/signal/util/ErrorUtils.java b/src/main/java/org/asamk/signal/util/ErrorUtils.java index ef1956c3..c3ecf340 100644 --- a/src/main/java/org/asamk/signal/util/ErrorUtils.java +++ b/src/main/java/org/asamk/signal/util/ErrorUtils.java @@ -2,11 +2,11 @@ package org.asamk.signal.util; import org.asamk.signal.commands.exceptions.CommandException; import org.asamk.signal.commands.exceptions.IOErrorException; +import org.asamk.signal.manager.api.ProofRequiredException; import org.asamk.signal.manager.api.RecipientIdentifier; +import org.asamk.signal.manager.api.SendMessageResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.whispersystems.signalservice.api.messages.SendMessageResult; -import org.whispersystems.signalservice.api.push.exceptions.ProofRequiredException; import java.util.ArrayList; import java.util.Collection; @@ -14,8 +14,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static org.asamk.signal.util.Util.getLegacyIdentifier; - public class ErrorUtils { private final static Logger logger = LoggerFactory.getLogger(ErrorUtils.class); @@ -57,17 +55,21 @@ public class ErrorUtils { } public static String getErrorMessageFromSendMessageResult(SendMessageResult result) { - var identifier = getLegacyIdentifier(result.getAddress()); - if (result.isNetworkFailure()) { - return String.format("Network failure for \"%s\"", identifier); - } else if (result.isUnregisteredFailure()) { - return String.format("Unregistered user \"%s\"", identifier); - } else if (result.getIdentityFailure() != null) { - return String.format("Untrusted Identity for \"%s\"", identifier); - } else if (result.getProofRequiredFailure() != null) { - final var failure = result.getProofRequiredFailure(); + var identifier = result.address().getLegacyIdentifier(); + if (result.proofRequiredFailure() != null) { + final var failure = result.proofRequiredFailure(); return String.format( - "CAPTCHA proof required for sending to \"%s\", available options \"%s\" with challenge token \"%s\", or wait \"%d\" seconds", + "CAPTCHA proof required for sending to \"%s\", available options \"%s\" with challenge token \"%s\", or wait \"%d\" seconds.\n" + + ( + failure.getOptions().contains(ProofRequiredException.Option.RECAPTCHA) + ? """ + To get the captcha token, go to https://signalcaptchas.org/challenge/generate.html + Check the developer tools (F12) console for a failed redirect to signalcaptcha:// + Everything after signalcaptcha:// is the captcha token. + Use the following command to submit the captcha token: + signal-cli submitRateLimitChallenge --challenge CHALLENGE_TOKEN --captcha CAPTCHA_TOKEN""" + : "" + ), identifier, failure.getOptions() .stream() @@ -75,6 +77,12 @@ public class ErrorUtils { .collect(Collectors.joining(", ")), failure.getToken(), failure.getRetryAfterSeconds()); + } else if (result.isNetworkFailure()) { + return String.format("Network failure for \"%s\"", identifier); + } else if (result.isUnregisteredFailure()) { + return String.format("Unregistered user \"%s\"", identifier); + } else if (result.isIdentityFailure()) { + return String.format("Untrusted Identity for \"%s\"", identifier); } return null; }