Lazily get captcha clients to avoid initialization issues

This commit is contained in:
Ameya Lokare
2024-10-22 05:07:37 -07:00
parent 39b1935350
commit 997129871c
4 changed files with 25 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ import io.dropwizard.configuration.ConfigurationValidationException;
import io.dropwizard.lifecycle.Managed;
import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import javax.validation.Validator;
import org.whispersystems.textsecuregcm.captcha.CaptchaChecker;
import org.whispersystems.textsecuregcm.captcha.CaptchaClient;
@@ -84,5 +85,12 @@ public interface SpamFilter extends Managed {
*/
RegistrationRecoveryChecker getRegistrationRecoveryChecker();
List<CaptchaClient> getCaptchaClients();
/**
* Return a function that will be used to lazily fetch the captcha client for a specified scheme. This is to avoid
* initialization issues with the spam filter if eagerly fetched.
*
* @return a {@link Function} that takes the scheme and returns a {@link CaptchaClient}. Returns null if no captcha
* client for the scheme exists
*/
Function<String, CaptchaClient> getCaptchaClientSupplier();
}