From 099073356c279c2cca0cb8770936f222712b3a9a Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Mon, 7 Apr 2025 12:45:12 -0400 Subject: [PATCH] Make destination service identifiers for spam checks non-optional --- .../controllers/MessageController.java | 2 +- .../textsecuregcm/spam/SpamChecker.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java index 04bad8e87..fa0251c55 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java @@ -305,7 +305,7 @@ public class MessageController { } final SpamCheckResult spamCheckResult = - spamChecker.checkForIndividualRecipientSpamHttp(messageType, context, source, maybeDestination, Optional.of(destinationIdentifier)); + spamChecker.checkForIndividualRecipientSpamHttp(messageType, context, source, maybeDestination, destinationIdentifier); if (spamCheckResult.response().isPresent()) { return spamCheckResult.response().get(); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamChecker.java b/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamChecker.java index 53921acd2..42058cd79 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamChecker.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/spam/SpamChecker.java @@ -19,10 +19,12 @@ public interface SpamChecker { /** * Determine if a message sent to an individual recipient via HTTP may be spam. * - * @param requestContext The request context for a message send attempt - * @param maybeSource The sender of the message, could be empty if this as message sent with sealed sender - * @param maybeDestination The destination of the message, could be empty if the destination does not exist or could + * @param messageType the type of message to check + * @param requestContext the request context for a message send attempt + * @param maybeSource the sender of the message, could be empty if this as message sent with sealed sender + * @param maybeDestination the destination of the message, could be empty if the destination does not exist or could * not be retrieved + * @param destinationIdentifier the service identifier for the destination account * @return A {@link SpamCheckResult} */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @@ -31,12 +33,13 @@ public interface SpamChecker { final ContainerRequestContext requestContext, final Optional maybeSource, final Optional maybeDestination, - final Optional maybeDestinationIdentifier); + final ServiceIdentifier destinationIdentifier); /** * Determine if a message sent to multiple recipients via HTTP may be spam. * - * @param requestContext The request context for a message send attempt + * @param messageType the type of message to check + * @param requestContext the request context for a message send attempt * @return A {@link SpamCheckResult} */ SpamCheckResult checkForMultiRecipientSpamHttp( @@ -46,9 +49,11 @@ public interface SpamChecker { /** * Determine if a message sent to an individual recipient via gRPC may be spam. * - * @param maybeSource The sender of the message, could be empty if this as message sent with sealed sender - * @param maybeDestination The destination of the message, could be empty if the destination does not exist or could + * @param messageType the type of message to check + * @param maybeSource the sender of the message, could be empty if this as message sent with sealed sender + * @param maybeDestination the destination of the message, could be empty if the destination does not exist or could * not be retrieved + * @param destinationIdentifier the service identifier for the destination account * @return A {@link SpamCheckResult} */ @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @@ -56,11 +61,13 @@ public interface SpamChecker { final MessageType messageType, final Optional maybeSource, final Optional maybeDestination, - final Optional maybeDestinationIdentifier); + final ServiceIdentifier destinationIdentifier); /** * Determine if a message sent to multiple recipients via gRPC may be spam. * + * @param messageType the type of message to check + * * @return A {@link SpamCheckResult} */ SpamCheckResult> checkForMultiRecipientSpamGrpc(final MessageType messageType); @@ -74,7 +81,7 @@ public interface SpamChecker { final ContainerRequestContext requestContext, final Optional maybeSource, final Optional maybeDestination, - final Optional maybeDestinationIdentifier) { + final ServiceIdentifier destinationIdentifier) { return new SpamCheckResult<>(Optional.empty(), Optional.empty()); } @@ -90,7 +97,7 @@ public interface SpamChecker { public SpamCheckResult> checkForIndividualRecipientSpamGrpc(final MessageType messageType, final Optional maybeSource, final Optional maybeDestination, - final Optional maybeDestinationIdentifier) { + final ServiceIdentifier destinationIdentifier) { return new SpamCheckResult<>(Optional.empty(), Optional.empty()); }