From 1ce1c298d3f4f221e168e2ae58a10075dbd582a3 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Fri, 21 Nov 2025 12:37:05 -0500 Subject: [PATCH] Add hooks so spam filters can register Dropwizard commands --- .../textsecuregcm/WhisperServerService.java | 6 ++++++ .../whispersystems/textsecuregcm/spam/SpamFilter.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 0f602004a..cb4aabc54 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -355,6 +355,12 @@ public class WhisperServerService extends Application spamFilter.getCommands().stream()) + .forEach(bootstrap::addCommand); } @Override diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamFilter.java b/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamFilter.java index 1aaa4877f..2995b3ded 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamFilter.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamFilter.java @@ -6,10 +6,13 @@ package org.whispersystems.textsecuregcm.spam; import io.dropwizard.configuration.ConfigurationValidationException; +import io.dropwizard.core.cli.ConfiguredCommand; import io.dropwizard.lifecycle.Managed; import jakarta.validation.Validator; import java.io.IOException; +import java.util.Collection; import java.util.function.Function; +import org.whispersystems.textsecuregcm.WhisperServerConfiguration; import org.whispersystems.textsecuregcm.captcha.CaptchaClient; import org.whispersystems.textsecuregcm.storage.ReportedMessageListener; @@ -35,6 +38,14 @@ public interface SpamFilter extends Managed { */ void configure(String environmentName, Validator validator) throws IOException, ConfigurationValidationException; + /** + * Returns a collection of commands provided by this spam filter. Note that this method may be called before + * {@link #configure(String, Validator)}. + * + * @return a collection of commands provided by this spam filter + */ + Collection> getCommands(); + /** * Return a reported message listener controlled by the spam filter. Listeners will be registered with the * {@link org.whispersystems.textsecuregcm.storage.ReportMessageManager}.