From 2902ea6689c1b6fae58fd610b52cc2f295f51fb2 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 17 Aug 2015 20:39:21 -0700 Subject: [PATCH] Get rid of deprecated API // FREEBIE --- .../controllers/MessageController.java | 38 ------------------- .../controllers/MessageControllerTest.java | 16 +------- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java b/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java index fa8eba354..39bd87426 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java +++ b/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java @@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.entities.IncomingMessage; import org.whispersystems.textsecuregcm.entities.IncomingMessageList; import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope; -import org.whispersystems.textsecuregcm.entities.MessageResponse; import org.whispersystems.textsecuregcm.entities.MismatchedDevices; import org.whispersystems.textsecuregcm.entities.OutgoingMessageEntity; import org.whispersystems.textsecuregcm.entities.OutgoingMessageEntityList; @@ -49,7 +48,6 @@ import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -129,26 +127,6 @@ public class MessageController { } } - @Timed - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public MessageResponse sendMessageLegacy(@Auth Account source, @Valid IncomingMessageList messages) - throws IOException, RateLimitExceededException - { - try { - List incomingMessages = messages.getMessages(); - validateLegacyDestinations(incomingMessages); - - messages.setRelay(incomingMessages.get(0).getRelay()); - sendMessage(source, incomingMessages.get(0).getDestination(), messages); - - return new MessageResponse(new LinkedList(), new LinkedList()); - } catch (ValidationException e) { - throw new WebApplicationException(Response.status(422).build()); - } - } - @Timed @GET @Produces(MediaType.APPLICATION_JSON) @@ -332,22 +310,6 @@ public class MessageController { } } - private void validateLegacyDestinations(List messages) - throws ValidationException - { - String destination = null; - - for (IncomingMessage message : messages) { - if ((message.getDestination() == null) || - (destination != null && !destination.equals(message.getDestination()))) - { - throw new ValidationException("Multiple account destinations!"); - } - - destination = message.getDestination(); - } - } - private Optional getMessageBody(IncomingMessage message) { if (Util.isEmpty(message.getBody())) return Optional.absent(); diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java index 9d9386a35..95dbf7d16 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java @@ -91,21 +91,7 @@ public class MessageControllerTest { when(rateLimiters.getMessagesLimiter()).thenReturn(rateLimiter); } - - @Test - public synchronized void testSingleDeviceLegacy() throws Exception { - Response response = - resources.getJerseyTest().target("/v1/messages/") - .request() - .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD)) - .post(Entity.entity(mapper.readValue(jsonFixture("fixtures/legacy_message_single_device.json"), IncomingMessageList.class), - MediaType.APPLICATION_JSON_TYPE)); - - assertThat("Good Response", response.getStatus(), is(equalTo(200))); - - verify(pushSender, times(1)).sendMessage(any(Account.class), any(Device.class), any(Envelope.class)); - } - + @Test public synchronized void testSingleDeviceCurrent() throws Exception { Response response =