Remove unused classes and methods
This commit is contained in:
parent
7a5615182a
commit
fef37f739b
|
@ -7,7 +7,6 @@ package org.whispersystems.textsecuregcm.controllers;
|
||||||
import com.amazonaws.HttpMethod;
|
import com.amazonaws.HttpMethod;
|
||||||
import com.codahale.metrics.annotation.Timed;
|
import com.codahale.metrics.annotation.Timed;
|
||||||
import io.dropwizard.auth.Auth;
|
import io.dropwizard.auth.Auth;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
@ -43,18 +42,15 @@ public class AttachmentControllerV1 extends AttachmentControllerBase {
|
||||||
@Timed
|
@Timed
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public AttachmentDescriptorV1 allocateAttachment(@Auth AuthenticatedAccount auth)
|
public AttachmentDescriptorV1 allocateAttachment(@Auth AuthenticatedAccount auth) throws RateLimitExceededException {
|
||||||
throws RateLimitExceededException {
|
|
||||||
if (auth.getAccount().isRateLimited()) {
|
rateLimiters.getAttachmentLimiter().validate(auth.getAccount().getUuid());
|
||||||
rateLimiters.getAttachmentLimiter().validate(auth.getAccount().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
long attachmentId = generateAttachmentId();
|
long attachmentId = generateAttachmentId();
|
||||||
URL url = urlSigner.getPreSignedUrl(attachmentId, HttpMethod.PUT,
|
URL url = urlSigner.getPreSignedUrl(attachmentId, HttpMethod.PUT,
|
||||||
Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region)));
|
Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region)));
|
||||||
|
|
||||||
return new AttachmentDescriptorV1(attachmentId, url.toExternalForm());
|
return new AttachmentDescriptorV1(attachmentId, url.toExternalForm());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Timed
|
@Timed
|
||||||
|
@ -62,8 +58,7 @@ public class AttachmentControllerV1 extends AttachmentControllerBase {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/{attachmentId}")
|
@Path("/{attachmentId}")
|
||||||
public AttachmentUri redirectToAttachment(@Auth AuthenticatedAccount auth,
|
public AttachmentUri redirectToAttachment(@Auth AuthenticatedAccount auth,
|
||||||
@PathParam("attachmentId") long attachmentId)
|
@PathParam("attachmentId") long attachmentId) {
|
||||||
throws IOException {
|
|
||||||
return new AttachmentUri(urlSigner.getPreSignedUrl(attachmentId, HttpMethod.GET,
|
return new AttachmentUri(urlSigner.getPreSignedUrl(attachmentId, HttpMethod.GET,
|
||||||
Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region))));
|
Stream.of(UNACCELERATED_REGIONS).anyMatch(region -> auth.getAccount().getNumber().startsWith(region))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,10 +45,6 @@ public class ReceiptSender {
|
||||||
.setTimestamp(messageId)
|
.setTimestamp(messageId)
|
||||||
.setType(Envelope.Type.SERVER_DELIVERY_RECEIPT);
|
.setType(Envelope.Type.SERVER_DELIVERY_RECEIPT);
|
||||||
|
|
||||||
if (sourceAccount.getRelay().isPresent()) {
|
|
||||||
message.setRelay(sourceAccount.getRelay().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (final Device destinationDevice : destinationAccount.getDevices()) {
|
for (final Device destinationDevice : destinationAccount.getDevices()) {
|
||||||
try {
|
try {
|
||||||
messageSender.sendMessage(destinationAccount, destinationDevice, message.build(), false);
|
messageSender.sendMessage(destinationAccount, destinationDevice, message.build(), false);
|
||||||
|
|
|
@ -282,12 +282,6 @@ public class Account {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRateLimited() {
|
|
||||||
requireNotStale();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanonicallyDiscoverable() {
|
public boolean isCanonicallyDiscoverable() {
|
||||||
requireNotStale();
|
requireNotStale();
|
||||||
|
|
||||||
|
@ -300,12 +294,6 @@ public class Account {
|
||||||
this.canonicallyDiscoverable = canonicallyDiscoverable;
|
this.canonicallyDiscoverable = canonicallyDiscoverable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getRelay() {
|
|
||||||
requireNotStale();
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdentityKey(String identityKey) {
|
public void setIdentityKey(String identityKey) {
|
||||||
requireNotStale();
|
requireNotStale();
|
||||||
|
|
||||||
|
|
|
@ -165,11 +165,6 @@ public class AccountsHelper {
|
||||||
when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
|
when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "getRelay": {
|
|
||||||
// TODO unused
|
|
||||||
when(updatedAccount.getRelay()).thenAnswer(stubbing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "getRegistrationLock": {
|
case "getRegistrationLock": {
|
||||||
when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);
|
when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class AuthHelper {
|
||||||
public static final UUID VALID_UUID_TWO = UUID.randomUUID();
|
public static final UUID VALID_UUID_TWO = UUID.randomUUID();
|
||||||
public static final String VALID_PASSWORD_TWO = "baz";
|
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 UUID INVALID_UUID = UUID.randomUUID();
|
||||||
public static final String INVALID_PASSWORD = "bar";
|
public static final String INVALID_PASSWORD = "bar";
|
||||||
|
|
||||||
|
@ -121,10 +120,6 @@ public class AuthHelper {
|
||||||
when(UNDISCOVERABLE_ACCOUNT.getNumber()).thenReturn(UNDISCOVERABLE_NUMBER);
|
when(UNDISCOVERABLE_ACCOUNT.getNumber()).thenReturn(UNDISCOVERABLE_NUMBER);
|
||||||
when(UNDISCOVERABLE_ACCOUNT.getUuid()).thenReturn(UNDISCOVERABLE_UUID);
|
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.isEnabled()).thenReturn(true);
|
||||||
when(VALID_ACCOUNT_TWO.isEnabled()).thenReturn(true);
|
when(VALID_ACCOUNT_TWO.isEnabled()).thenReturn(true);
|
||||||
when(DISABLED_ACCOUNT.isEnabled()).thenReturn(false);
|
when(DISABLED_ACCOUNT.isEnabled()).thenReturn(false);
|
||||||
|
@ -221,7 +216,6 @@ public class AuthHelper {
|
||||||
when(account.getMasterDevice()).thenReturn(Optional.of(device));
|
when(account.getMasterDevice()).thenReturn(Optional.of(device));
|
||||||
when(account.getNumber()).thenReturn(number);
|
when(account.getNumber()).thenReturn(number);
|
||||||
when(account.getUuid()).thenReturn(uuid);
|
when(account.getUuid()).thenReturn(uuid);
|
||||||
when(account.getRelay()).thenReturn(Optional.empty());
|
|
||||||
when(account.isEnabled()).thenReturn(true);
|
when(account.isEnabled()).thenReturn(true);
|
||||||
when(accountsManager.getByE164(number)).thenReturn(Optional.of(account));
|
when(accountsManager.getByE164(number)).thenReturn(Optional.of(account));
|
||||||
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
when(accountsManager.getByAccountIdentifier(uuid)).thenReturn(Optional.of(account));
|
||||||
|
|
Loading…
Reference in New Issue