That fuck shit the fascists are using
at master 55 lines 1.5 kB view raw
1package org.tm.archive.keyvalue; 2 3import androidx.annotation.NonNull; 4 5import org.greenrobot.eventbus.EventBus; 6import org.signal.core.util.logging.Log; 7import org.tm.archive.ratelimit.RecaptchaRequiredEvent; 8 9import java.util.Collections; 10import java.util.List; 11 12public final class RateLimitValues extends SignalStoreValues { 13 14 private static final String TAG = Log.tag(RateLimitValues.class); 15 16 private static final String KEY_NEEDS_RECAPTCHA = "ratelimit.needs_recaptcha"; 17 private static final String KEY_CHALLENGE = "ratelimit.token"; 18 19 RateLimitValues(@NonNull KeyValueStore store) { 20 super(store); 21 } 22 23 @Override 24 void onFirstEverAppLaunch() { 25 } 26 27 @Override 28 @NonNull List<String> getKeysToIncludeInBackup() { 29 return Collections.emptyList(); 30 } 31 32 /** 33 * @param challenge The token associated with the rate limit response. 34 */ 35 public void markNeedsRecaptcha(@NonNull String challenge) { 36 Log.i(TAG, "markNeedsRecaptcha()"); 37 putBoolean(KEY_NEEDS_RECAPTCHA, true); 38 putString(KEY_CHALLENGE, challenge); 39 EventBus.getDefault().post(new RecaptchaRequiredEvent()); 40 } 41 42 public void onProofAccepted() { 43 Log.i(TAG, "onProofAccepted()", new Throwable()); 44 putBoolean(KEY_NEEDS_RECAPTCHA, false); 45 remove(KEY_CHALLENGE); 46 } 47 48 public boolean needsRecaptcha() { 49 return getBoolean(KEY_NEEDS_RECAPTCHA, false); 50 } 51 52 public @NonNull String getChallenge() { 53 return getString(KEY_CHALLENGE, ""); 54 } 55}