Update Option.RECAPTCHA to Option.CAPTCHA

This commit is contained in:
Chris Eager 2024-03-14 09:52:26 -05:00 committed by Cody Henthorne
parent 8f884fdd5c
commit 0c6761fcfd
3 changed files with 11 additions and 4 deletions

View file

@ -594,8 +594,13 @@ public abstract class PushSendJob extends SendJob {
SignalDatabase.messages().markAsRateLimited(messageId); SignalDatabase.messages().markAsRateLimited(messageId);
} }
if (proofRequired.getOptions().contains(ProofRequiredException.Option.RECAPTCHA)) { final Optional<ProofRequiredException.Option> captchaRequired =
Log.i(TAG, "[Proof Required] ReCAPTCHA required."); proofRequired.getOptions().stream()
.filter(option -> option.equals(ProofRequiredException.Option.RECAPTCHA) || option.equals(ProofRequiredException.Option.CAPTCHA))
.findFirst();
if (captchaRequired.isPresent()) {
Log.i(TAG, "[Proof Required] " + captchaRequired.get() + " required.");
SignalStore.rateLimit().markNeedsRecaptcha(proofRequired.getToken()); SignalStore.rateLimit().markNeedsRecaptcha(proofRequired.getToken());
if (recipient != null) { if (recipient != null) {

View file

@ -44,6 +44,8 @@ public class ProofRequiredException extends NonSuccessfulResponseCodeException {
switch (raw) { switch (raw) {
case "recaptcha": case "recaptcha":
options.add(Option.RECAPTCHA); options.add(Option.RECAPTCHA);
case "captcha":
options.add(Option.CAPTCHA);
break; break;
case "pushChallenge": case "pushChallenge":
options.add(Option.PUSH_CHALLENGE); options.add(Option.PUSH_CHALLENGE);
@ -58,6 +60,6 @@ public class ProofRequiredException extends NonSuccessfulResponseCodeException {
} }
public enum Option { public enum Option {
RECAPTCHA, PUSH_CHALLENGE @Deprecated RECAPTCHA, CAPTCHA, PUSH_CHALLENGE
} }
} }

View file

@ -16,7 +16,7 @@ class SubmitRecaptchaChallengePayload {
public SubmitRecaptchaChallengePayload() {} public SubmitRecaptchaChallengePayload() {}
public SubmitRecaptchaChallengePayload(String challenge, String recaptchaToken) { public SubmitRecaptchaChallengePayload(String challenge, String recaptchaToken) {
this.type = "recaptcha"; this.type = "captcha";
this.token = challenge; this.token = challenge;
this.captcha = recaptchaToken; this.captcha = recaptchaToken;
} }