Pass in destination service identifier to spam filter
This commit is contained in:
parent
830a07012b
commit
d48c031548
|
@ -326,7 +326,7 @@ public class MessageController {
|
||||||
}
|
}
|
||||||
|
|
||||||
final SpamChecker.SpamCheckResult spamCheck = spamChecker.checkForSpam(
|
final SpamChecker.SpamCheckResult spamCheck = spamChecker.checkForSpam(
|
||||||
context, source, destination);
|
context, source, destination, Optional.of(destinationIdentifier));
|
||||||
final Optional<byte[]> reportSpamToken;
|
final Optional<byte[]> reportSpamToken;
|
||||||
switch (spamCheck) {
|
switch (spamCheck) {
|
||||||
case final SpamChecker.Spam spam: return spam.response();
|
case final SpamChecker.Spam spam: return spam.response();
|
||||||
|
@ -547,7 +547,7 @@ public class MessageController {
|
||||||
|
|
||||||
@Context ContainerRequestContext context) throws RateLimitExceededException {
|
@Context ContainerRequestContext context) throws RateLimitExceededException {
|
||||||
|
|
||||||
final SpamChecker.SpamCheckResult spamCheck = spamChecker.checkForSpam(context, Optional.empty(), Optional.empty());
|
final SpamChecker.SpamCheckResult spamCheck = spamChecker.checkForSpam(context, Optional.empty(), Optional.empty(), Optional.empty());
|
||||||
if (spamCheck instanceof final SpamChecker.Spam spam) {
|
if (spamCheck instanceof final SpamChecker.Spam spam) {
|
||||||
return spam.response();
|
return spam.response();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package org.whispersystems.textsecuregcm.spam;
|
package org.whispersystems.textsecuregcm.spam;
|
||||||
|
|
||||||
import org.whispersystems.textsecuregcm.auth.AccountAndAuthenticatedDeviceHolder;
|
import org.whispersystems.textsecuregcm.auth.AccountAndAuthenticatedDeviceHolder;
|
||||||
|
import org.whispersystems.textsecuregcm.identity.ServiceIdentifier;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import javax.ws.rs.container.ContainerRequestContext;
|
import javax.ws.rs.container.ContainerRequestContext;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
@ -43,9 +44,10 @@ public interface SpamChecker {
|
||||||
SpamCheckResult checkForSpam(
|
SpamCheckResult checkForSpam(
|
||||||
final ContainerRequestContext requestContext,
|
final ContainerRequestContext requestContext,
|
||||||
final Optional<? extends AccountAndAuthenticatedDeviceHolder> maybeSource,
|
final Optional<? extends AccountAndAuthenticatedDeviceHolder> maybeSource,
|
||||||
final Optional<Account> maybeDestination);
|
final Optional<Account> maybeDestination,
|
||||||
|
final Optional<ServiceIdentifier> destinationIdentifier);
|
||||||
|
|
||||||
static SpamChecker noop() {
|
static SpamChecker noop() {
|
||||||
return (ignoredContext, ignoredSource, ignoredDestination) -> NotSpam.EMPTY_TOKEN;
|
return (ignoredContext, ignoredSource, ignoredDestination, ignoredDestinationIdentifier) -> NotSpam.EMPTY_TOKEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue