mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
parent
1856e79a50
commit
eee140f74f
4 changed files with 60 additions and 1 deletions
|
@ -405,6 +405,10 @@ public class Manager implements Closeable {
|
||||||
account.setRegistered(false);
|
account.setRegistered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void submitRateLimitRecaptchaChallenge(String challenge, String captcha) throws IOException {
|
||||||
|
dependencies.getAccountManager().submitRateLimitRecaptchaChallenge(challenge, captcha);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Device> getLinkedDevices() throws IOException {
|
public List<Device> getLinkedDevices() throws IOException {
|
||||||
var devices = dependencies.getAccountManager().getDevices();
|
var devices = dependencies.getAccountManager().getDevices();
|
||||||
account.setMultiDevice(devices.size() > 1);
|
account.setMultiDevice(devices.size() > 1);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class Commands {
|
||||||
addCommand(new SendSyncRequestCommand());
|
addCommand(new SendSyncRequestCommand());
|
||||||
addCommand(new SendTypingCommand());
|
addCommand(new SendTypingCommand());
|
||||||
addCommand(new SetPinCommand());
|
addCommand(new SetPinCommand());
|
||||||
|
addCommand(new SubmitRateLimitChallengeCommand());
|
||||||
addCommand(new TrustCommand());
|
addCommand(new TrustCommand());
|
||||||
addCommand(new UnblockCommand());
|
addCommand(new UnblockCommand());
|
||||||
addCommand(new UnregisterCommand());
|
addCommand(new UnregisterCommand());
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.asamk.signal.commands;
|
||||||
|
|
||||||
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
|
import org.asamk.signal.OutputWriter;
|
||||||
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class SubmitRateLimitChallengeCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "submitRateLimitChallenge";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
|
subparser.help(
|
||||||
|
"Submit a captcha challenge to lift the rate limit. This command should only be necessary when sending fails with a proof required error.");
|
||||||
|
subparser.addArgument("--challenge")
|
||||||
|
.required(true)
|
||||||
|
.help("The challenge token taken from the proof required error.");
|
||||||
|
subparser.addArgument("--captcha")
|
||||||
|
.required(true)
|
||||||
|
.help("The captcha token from the solved captcha on the signal website.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCommand(final Namespace ns, final Manager m, OutputWriter outputWriter) throws CommandException {
|
||||||
|
final var challenge = ns.getString("challenge");
|
||||||
|
final var captchaString = ns.getString("captcha");
|
||||||
|
final var captcha = captchaString == null ? null : captchaString.replace("signalcaptcha://", "");
|
||||||
|
|
||||||
|
try {
|
||||||
|
m.submitRateLimitRecaptchaChallenge(challenge, captcha);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IOErrorException("Submit challenge error: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,7 +67,17 @@ public class ErrorUtils {
|
||||||
} else if (result.getProofRequiredFailure() != null) {
|
} else if (result.getProofRequiredFailure() != null) {
|
||||||
final var failure = result.getProofRequiredFailure();
|
final var failure = result.getProofRequiredFailure();
|
||||||
return String.format(
|
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/registration/generate.html\n"
|
||||||
|
+ "Check the developer tools (F12) console for a failed redirect to signalcaptcha://\n"
|
||||||
|
+ "Everything after signalcaptcha:// is the captcha token.\n"
|
||||||
|
+ "Use the following command to submit the captcha token:\n"
|
||||||
|
+ "signal-cli submitRateLimitChallenge --challenge CHALLENGE_TOKEN --captcha CAPTCHA_TOKEN"
|
||||||
|
: ""
|
||||||
|
),
|
||||||
identifier,
|
identifier,
|
||||||
failure.getOptions()
|
failure.getOptions()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue