X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/69e952738bd6300940ac3845792f052fe57eb58d..74e5f386fb70f6c114c5d390c899c48351e0187b:/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 cf2b282f..e4386b0e 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"); } @@ -85,8 +90,7 @@ 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. + After solving the captcha, right-click on the "Open Signal" link and copy the link. Use the following command to submit the captcha token: signal-cli submitRateLimitChallenge --challenge CHALLENGE_TOKEN --captcha CAPTCHA_TOKEN""" : "" @@ -111,7 +115,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:");