mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 07:36:47 +00:00
Add hooks so spam filters can register Dropwizard commands
This commit is contained in:
1 parent
4d5cc4dc22
commit
1ce1c298d3
2 files changed
+17
No files matched your search
@@ -355,6 +355,12 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
new IdleDeviceNotificationSchedulerFactory()));
|
||||
|
||||
bootstrap.addCommand(new RegenerateSecondaryDynamoDbTableDataCommand());
|
||||
|
||||
ServiceLoader.load(SpamFilter.class)
|
||||
.stream()
|
||||
.map(ServiceLoader.Provider::get)
|
||||
.flatMap(spamFilter -> spamFilter.getCommands().stream())
|
||||
.forEach(bootstrap::addCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<ConfiguredCommand<WhisperServerConfiguration>> getCommands();
|
||||
|
||||
/**
|
||||
* Return a reported message listener controlled by the spam filter. Listeners will be registered with the
|
||||
* {@link org.whispersystems.textsecuregcm.storage.ReportMessageManager}.
|
||||
|
||||
Reference in new issue
Block a user