X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/467a48bac508b56f84dce7ee0b81a22fd0d32161..ce70a623c21a267679d59838d041f9bc1d486cd9:/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 8a3de142..1c8a8f38 100644 --- a/src/main/java/org/asamk/signal/util/ErrorUtils.java +++ b/src/main/java/org/asamk/signal/util/ErrorUtils.java @@ -58,16 +58,20 @@ 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) { + if (result.getProofRequiredFailure() != null) { final var failure = result.getProofRequiredFailure(); return String.format( - "CAPTCHA proof required for sending to \"%s\", available options \"%s\" with 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 +79,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.getIdentityFailure() != null) { + return String.format("Untrusted Identity for \"%s\"", identifier); } return null; } @@ -88,6 +98,6 @@ public class ErrorUtils { for (var error : errors) { message.append(error).append("\n"); } - throw new IOErrorException(message.toString()); + throw new IOErrorException(message.toString(), null); } }