X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/942999b7b4beebf4519eed9b216587519b47e6c6..2c5d1f85503b382f08a1ac6eb2e4e49ee3951f9b:/src/main/java/org/asamk/signal/util/SendMessageResultUtils.java diff --git a/src/main/java/org/asamk/signal/util/SendMessageResultUtils.java b/src/main/java/org/asamk/signal/util/SendMessageResultUtils.java index a7739c23..ecc669e8 100644 --- a/src/main/java/org/asamk/signal/util/SendMessageResultUtils.java +++ b/src/main/java/org/asamk/signal/util/SendMessageResultUtils.java @@ -1,10 +1,12 @@ package org.asamk.signal.util; import org.asamk.signal.commands.exceptions.CommandException; +import org.asamk.signal.commands.exceptions.RateLimitErrorException; import org.asamk.signal.commands.exceptions.UntrustedKeyErrorException; import org.asamk.signal.commands.exceptions.UserErrorException; import org.asamk.signal.json.JsonSendMessageResult; import org.asamk.signal.manager.api.ProofRequiredException; +import org.asamk.signal.manager.api.RateLimitException; import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.SendGroupMessageResults; import org.asamk.signal.manager.api.SendMessageResult; @@ -51,6 +53,9 @@ public class SendMessageResultUtils { if (!sendMessageResults.hasSuccess()) { if (sendMessageResults.hasOnlyUntrustedIdentity()) { throw new UntrustedKeyErrorException("Failed to send message due to untrusted identities"); + } else if (sendMessageResults.hasOnlyRateLimitFailure()) { + throw new RateLimitErrorException("Failed to send message due to rate limiting", + new RateLimitException(0)); } else { throw new UserErrorException("Failed to send message"); } @@ -84,11 +89,11 @@ public class SendMessageResultUtils { + ( 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""" + 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, @@ -111,7 +116,7 @@ public class SendMessageResultUtils { } public static void printSendMessageResultErrors(PlainTextWriter writer, List errors) { - if (errors.size() == 0) { + if (errors.isEmpty()) { return; } writer.println("Failed to send (some) messages:");