diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV1.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV1.java index 4c6365d52..4ffc65cd0 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV1.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AttachmentControllerV1.java @@ -7,7 +7,6 @@ package org.whispersystems.textsecuregcm.controllers; import com.amazonaws.HttpMethod; import com.codahale.metrics.annotation.Timed; import io.dropwizard.auth.Auth; -import java.io.IOException; import java.net.URL; import java.util.stream.Stream; import javax.ws.rs.GET; @@ -43,18 +42,15 @@ public class AttachmentControllerV1 extends AttachmentControllerBase { @Timed @GET @Produces(MediaType.APPLICATION_JSON) - public AttachmentDescriptorV1 allocateAttachment(@Auth AuthenticatedAccount auth) - throws RateLimitExceededException { - if (auth.getAccount().isRateLimited()) { - rateLimiters.getAttachmentLimiter().validate(auth.getAccount().getUuid()); - } + public AttachmentDescriptorV1 allocateAttachment(@Auth AuthenticatedAccount auth) throws RateLimitExceededException { + + rateLimiters.getAttachmentLimiter().validate(auth.getAccount().getUuid()); long attachmentId = generateAttachmentId(); URL url = urlSigner.getPreSignedUrl(attachmentId, HttpMethod.PUT, Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region))); return new AttachmentDescriptorV1(attachmentId, url.toExternalForm()); - } @Timed @@ -62,8 +58,7 @@ public class AttachmentControllerV1 extends AttachmentControllerBase { @Produces(MediaType.APPLICATION_JSON) @Path("/{attachmentId}") public AttachmentUri redirectToAttachment(@Auth AuthenticatedAccount auth, - @PathParam("attachmentId") long attachmentId) - throws IOException { + @PathParam("attachmentId") long attachmentId) { return new AttachmentUri(urlSigner.getPreSignedUrl(attachmentId, HttpMethod.GET, Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region)))); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ValidationException.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ValidationException.java deleted file mode 100644 index ef7ace6a7..000000000 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ValidationException.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2013-2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only - */ -package org.whispersystems.textsecuregcm.controllers; - - -public class ValidationException extends Exception { - public ValidationException(String s) { - super(s); - } -} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/providers/RedisHealthCheck.java b/service/src/main/java/org/whispersystems/textsecuregcm/providers/RedisHealthCheck.java deleted file mode 100644 index 18745ce52..000000000 --- a/service/src/main/java/org/whispersystems/textsecuregcm/providers/RedisHealthCheck.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only - */ -package org.whispersystems.textsecuregcm.providers; - -import com.codahale.metrics.health.HealthCheck; -import org.whispersystems.textsecuregcm.redis.ReplicatedJedisPool; - -import redis.clients.jedis.Jedis; - -public class RedisHealthCheck extends HealthCheck { - - private final ReplicatedJedisPool clientPool; - - public RedisHealthCheck(ReplicatedJedisPool clientPool) { - this.clientPool = clientPool; - } - - @Override - protected Result check() throws Exception { - try (Jedis client = clientPool.getWriteResource()) { - client.set("HEALTH", "test"); - - if (!"test".equals(client.get("HEALTH"))) { - return Result.unhealthy("fetch failed"); - } - - return Result.healthy(); - } - } -} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java index e7dab5540..82086054e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java @@ -45,10 +45,6 @@ public class ReceiptSender { .setTimestamp(messageId) .setType(Envelope.Type.SERVER_DELIVERY_RECEIPT); - if (sourceAccount.getRelay().isPresent()) { - message.setRelay(sourceAccount.getRelay().get()); - } - for (final Device destinationDevice : destinationAccount.getDevices()) { try { messageSender.sendMessage(destinationAccount, destinationDevice, message.build(), false); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java index b893da47c..817bd5cc4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java @@ -282,12 +282,6 @@ public class Account { return count; } - public boolean isRateLimited() { - requireNotStale(); - - return true; - } - public boolean isCanonicallyDiscoverable() { requireNotStale(); @@ -300,12 +294,6 @@ public class Account { this.canonicallyDiscoverable = canonicallyDiscoverable; } - public Optional getRelay() { - requireNotStale(); - - return Optional.empty(); - } - public void setIdentityKey(String identityKey) { requireNotStale(); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java index 4cdeb23b3..01a81d1c0 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AccountsHelper.java @@ -165,11 +165,6 @@ public class AccountsHelper { when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing); break; } - case "getRelay": { - // TODO unused - when(updatedAccount.getRelay()).thenAnswer(stubbing); - break; - } case "getRegistrationLock": { when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing); break; diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AuthHelper.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AuthHelper.java index d4dbadd1b..104b9946d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AuthHelper.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/util/AuthHelper.java @@ -44,7 +44,6 @@ public class AuthHelper { public static final UUID VALID_UUID_TWO = UUID.randomUUID(); public static final String VALID_PASSWORD_TWO = "baz"; - public static final String INVALID_NUMBER = "+14151111111"; public static final UUID INVALID_UUID = UUID.randomUUID(); public static final String INVALID_PASSWORD = "bar"; @@ -121,10 +120,6 @@ public class AuthHelper { when(UNDISCOVERABLE_ACCOUNT.getNumber()).thenReturn(UNDISCOVERABLE_NUMBER); when(UNDISCOVERABLE_ACCOUNT.getUuid()).thenReturn(UNDISCOVERABLE_UUID); - when(VALID_ACCOUNT.getRelay()).thenReturn(Optional.empty()); - when(VALID_ACCOUNT_TWO.getRelay()).thenReturn(Optional.empty()); - when(UNDISCOVERABLE_ACCOUNT.getRelay()).thenReturn(Optional.empty()); - when(VALID_ACCOUNT.isEnabled()).thenReturn(true); when(VALID_ACCOUNT_TWO.isEnabled()).thenReturn(true); when(DISABLED_ACCOUNT.isEnabled()).thenReturn(false); @@ -221,7 +216,6 @@ public class AuthHelper { when(account.getMasterDevice()).thenReturn(Optional.of(device)); when(account.getNumber()).thenReturn(number); when(account.getUuid()).thenReturn(uuid); - when(account.getRelay()).thenReturn(Optional.empty()); when(account.isEnabled()).thenReturn(true); when(accountsManager.getByE164(number)).thenReturn(Optional.of(account)); when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));