diff --git a/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 1e3f31edc..208c0d013 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -285,7 +285,6 @@ public class AccountController { Account account = new Account(); account.setNumber(number); - account.setSupportsSms(accountAttributes.getSupportsSms()); account.addDevice(device); accounts.create(account); diff --git a/src/main/java/org/whispersystems/textsecuregcm/controllers/FederationControllerV1.java b/src/main/java/org/whispersystems/textsecuregcm/controllers/FederationControllerV1.java index 64fd31b2f..6d924f13b 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/controllers/FederationControllerV1.java +++ b/src/main/java/org/whispersystems/textsecuregcm/controllers/FederationControllerV1.java @@ -150,7 +150,7 @@ public class FederationControllerV1 extends FederationController { for (Account account : accountList) { byte[] token = Util.getContactToken(account.getNumber()); - ClientContact clientContact = new ClientContact(token, null, account.getSupportsSms()); + ClientContact clientContact = new ClientContact(token, null); if (!account.isActive()) { clientContact.setInactive(true); diff --git a/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java b/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java index ff2eed12f..58cf85293 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java +++ b/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java @@ -25,9 +25,6 @@ public class AccountAttributes { @NotEmpty private String signalingKey; - @JsonProperty - private boolean supportsSms; - @JsonProperty private boolean fetchesMessages; @@ -36,9 +33,8 @@ public class AccountAttributes { public AccountAttributes() {} - public AccountAttributes(String signalingKey, boolean supportsSms, boolean fetchesMessages, int registrationId) { + public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId) { this.signalingKey = signalingKey; - this.supportsSms = supportsSms; this.fetchesMessages = fetchesMessages; this.registrationId = registrationId; } @@ -47,10 +43,6 @@ public class AccountAttributes { return signalingKey; } - public boolean getSupportsSms() { - return supportsSms; - } - public boolean getFetchesMessages() { return fetchesMessages; } diff --git a/src/main/java/org/whispersystems/textsecuregcm/entities/ClientContact.java b/src/main/java/org/whispersystems/textsecuregcm/entities/ClientContact.java index 14b2a5912..8c807d136 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/entities/ClientContact.java +++ b/src/main/java/org/whispersystems/textsecuregcm/entities/ClientContact.java @@ -34,12 +34,10 @@ public class ClientContact { private String relay; private boolean inactive; - private boolean supportsSms; - public ClientContact(byte[] token, String relay, boolean supportsSms) { - this.token = token; - this.relay = relay; - this.supportsSms = supportsSms; + public ClientContact(byte[] token, String relay) { + this.token = token; + this.relay = relay; } public ClientContact() {} @@ -56,10 +54,6 @@ public class ClientContact { this.relay = relay; } - public boolean isSupportsSms() { - return supportsSms; - } - public boolean isInactive() { return inactive; } @@ -81,7 +75,6 @@ public class ClientContact { return Arrays.equals(this.token, that.token) && - this.supportsSms == that.supportsSms && this.inactive == that.inactive && (this.relay == null ? (that.relay == null) : this.relay.equals(that.relay)); } diff --git a/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java b/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java index 62d9e9f8b..3e381e44d 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java +++ b/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java @@ -32,9 +32,6 @@ public class Account { @JsonProperty private String number; - @JsonProperty - private boolean supportsSms; - @JsonProperty private Set devices = new HashSet<>(); @@ -47,10 +44,9 @@ public class Account { public Account() {} @VisibleForTesting - public Account(String number, boolean supportsSms, Set devices) { - this.number = number; - this.supportsSms = supportsSms; - this.devices = devices; + public Account(String number, Set devices) { + this.number = number; + this.devices = devices; } public Optional getAuthenticatedDevice() { @@ -69,14 +65,6 @@ public class Account { return number; } - public boolean getSupportsSms() { - return supportsSms; - } - - public void setSupportsSms(boolean supportsSms) { - this.supportsSms = supportsSms; - } - public void addDevice(Device device) { this.devices.remove(device); this.devices.add(device); diff --git a/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java b/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java index 56dce8eb8..04a22f52f 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java +++ b/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java @@ -100,7 +100,7 @@ public class AccountsManager { private void updateDirectory(Account account) { if (account.isActive()) { byte[] token = Util.getContactToken(account.getNumber()); - ClientContact clientContact = new ClientContact(token, null, account.getSupportsSms()); + ClientContact clientContact = new ClientContact(token, null); directory.add(clientContact); } else { directory.remove(account.getNumber()); diff --git a/src/main/java/org/whispersystems/textsecuregcm/storage/DirectoryManager.java b/src/main/java/org/whispersystems/textsecuregcm/storage/DirectoryManager.java index 78c7e96a1..bf40ed068 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/storage/DirectoryManager.java +++ b/src/main/java/org/whispersystems/textsecuregcm/storage/DirectoryManager.java @@ -72,7 +72,7 @@ public class DirectoryManager { } public void add(ClientContact contact) { - TokenValue tokenValue = new TokenValue(contact.getRelay(), contact.isSupportsSms()); + TokenValue tokenValue = new TokenValue(contact.getRelay()); try (Jedis jedis = redisPool.getResource()) { jedis.hset(DIRECTORY_KEY, contact.getToken(), objectMapper.writeValueAsBytes(tokenValue)); @@ -84,7 +84,7 @@ public class DirectoryManager { public void add(BatchOperationHandle handle, ClientContact contact) { try { Pipeline pipeline = handle.pipeline; - TokenValue tokenValue = new TokenValue(contact.getRelay(), contact.isSupportsSms()); + TokenValue tokenValue = new TokenValue(contact.getRelay()); pipeline.hset(DIRECTORY_KEY, contact.getToken(), objectMapper.writeValueAsBytes(tokenValue)); } catch (JsonProcessingException e) { @@ -106,7 +106,7 @@ public class DirectoryManager { } TokenValue tokenValue = objectMapper.readValue(result, TokenValue.class); - return Optional.of(new ClientContact(token, tokenValue.relay, tokenValue.supportsSms)); + return Optional.of(new ClientContact(token, tokenValue.relay)); } catch (IOException e) { logger.warn("JSON Error", e); return Optional.absent(); @@ -133,7 +133,7 @@ public class DirectoryManager { try { if (pair.second().get() != null) { TokenValue tokenValue = objectMapper.readValue(pair.second().get(), TokenValue.class); - ClientContact clientContact = new ClientContact(pair.first(), tokenValue.relay, tokenValue.supportsSms); + ClientContact clientContact = new ClientContact(pair.first(), tokenValue.relay); results.add(clientContact); } @@ -175,14 +175,10 @@ public class DirectoryManager { @JsonProperty(value = "r") private String relay; - @JsonProperty(value = "s") - private boolean supportsSms; - public TokenValue() {} - public TokenValue(String relay, boolean supportsSms) { - this.relay = relay; - this.supportsSms = supportsSms; + public TokenValue(String relay) { + this.relay = relay; } } @@ -205,7 +201,7 @@ public class DirectoryManager { } TokenValue tokenValue = objectMapper.readValue(result, TokenValue.class); - return Optional.of(new ClientContact(token, tokenValue.relay, tokenValue.supportsSms)); + return Optional.of(new ClientContact(token, tokenValue.relay)); } } diff --git a/src/main/java/org/whispersystems/textsecuregcm/workers/DirectoryUpdater.java b/src/main/java/org/whispersystems/textsecuregcm/workers/DirectoryUpdater.java index d27b0e059..7b5d3cf96 100644 --- a/src/main/java/org/whispersystems/textsecuregcm/workers/DirectoryUpdater.java +++ b/src/main/java/org/whispersystems/textsecuregcm/workers/DirectoryUpdater.java @@ -73,7 +73,7 @@ public class DirectoryUpdater { for (Account account : accounts) { if (account.isActive()) { byte[] token = Util.getContactToken(account.getNumber()); - ClientContact clientContact = new ClientContact(token, null, account.getSupportsSms()); + ClientContact clientContact = new ClientContact(token, null); directory.add(batchOperation, clientContact); contactsAdded++; diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java index 8a15fd4dd..9f99bae09 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java @@ -83,7 +83,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/code/%s", "1234")) .header("Authorization", AuthHelper.getAuthHeader(SENDER, "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 2222)) + .entity(new AccountAttributes("keykeykeykey", false, 2222)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); @@ -97,7 +97,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/code/%s", "1111")) .header("Authorization", AuthHelper.getAuthHeader(SENDER, "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 3333)) + .entity(new AccountAttributes("keykeykeykey", false, 3333)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); @@ -115,7 +115,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/token/%s", token)) .header("Authorization", AuthHelper.getAuthHeader(SENDER, "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 4444)) + .entity(new AccountAttributes("keykeykeykey", false, 4444)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); @@ -133,7 +133,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/token/%s", token)) .header("Authorization", AuthHelper.getAuthHeader(SENDER, "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 4444)) + .entity(new AccountAttributes("keykeykeykey", false, 4444)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); @@ -151,7 +151,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/token/%s", token)) .header("Authorization", AuthHelper.getAuthHeader("+14151111111", "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 4444)) + .entity(new AccountAttributes("keykeykeykey", false, 4444)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); @@ -169,7 +169,7 @@ public class AccountControllerTest { ClientResponse response = resources.client().resource(String.format("/v1/accounts/token/%s", token)) .header("Authorization", AuthHelper.getAuthHeader(SENDER, "bar")) - .entity(new AccountAttributes("keykeykeykey", false, false, 4444)) + .entity(new AccountAttributes("keykeykeykey", false, 4444)) .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class); diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java index 03d9d2f24..d1de0e573 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java @@ -90,7 +90,7 @@ public class DeviceControllerTest { DeviceResponse response = resources.client().resource("/v1/devices/5678901") .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, "password1")) - .entity(new AccountAttributes("keykeykeykey", false, true, 1234)) + .entity(new AccountAttributes("keykeykeykey", false, 1234)) .type(MediaType.APPLICATION_JSON_TYPE) .put(DeviceResponse.class); diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/FederatedControllerTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/FederatedControllerTest.java index 2cc364511..909da6142 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/FederatedControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/FederatedControllerTest.java @@ -82,8 +82,8 @@ public class FederatedControllerTest { add(new Device(2, "foo", "bar", "baz", "isgcm", null, null, false, 333, null, System.currentTimeMillis())); }}; - Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, false, singleDeviceList); - Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, false, multiDeviceList); + Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, singleDeviceList); + Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, multiDeviceList); when(accountsManager.get(eq(SINGLE_DEVICE_RECIPIENT))).thenReturn(Optional.of(singleDeviceAccount)); when(accountsManager.get(eq(MULTI_DEVICE_RECIPIENT))).thenReturn(Optional.of(multiDeviceAccount)); 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 f6d081b35..342df3cf1 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/MessageControllerTest.java @@ -78,8 +78,8 @@ public class MessageControllerTest { add(new Device(3, "foo", "bar", "baz", "isgcm", null, null, false, 444, null, System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31))); }}; - Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, false, singleDeviceList); - Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, false, multiDeviceList); + Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, singleDeviceList); + Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, multiDeviceList); when(accountsManager.get(eq(SINGLE_DEVICE_RECIPIENT))).thenReturn(Optional.of(singleDeviceAccount)); when(accountsManager.get(eq(MULTI_DEVICE_RECIPIENT))).thenReturn(Optional.of(multiDeviceAccount)); diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ReceiptControllerTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ReceiptControllerTest.java index b721ed23a..a633f6638 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ReceiptControllerTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ReceiptControllerTest.java @@ -55,8 +55,8 @@ public class ReceiptControllerTest { add(new Device(2, "foo", "bar", "baz", "isgcm", null, null, false, 333, null, System.currentTimeMillis())); }}; - Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, false, singleDeviceList); - Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, false, multiDeviceList); + Account singleDeviceAccount = new Account(SINGLE_DEVICE_RECIPIENT, singleDeviceList); + Account multiDeviceAccount = new Account(MULTI_DEVICE_RECIPIENT, multiDeviceList); when(accountsManager.get(eq(SINGLE_DEVICE_RECIPIENT))).thenReturn(Optional.of(singleDeviceAccount)); when(accountsManager.get(eq(MULTI_DEVICE_RECIPIENT))).thenReturn(Optional.of(multiDeviceAccount)); diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/entities/ClientContactTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/entities/ClientContactTest.java index d1bf807d4..46a7ec78c 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/entities/ClientContactTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/entities/ClientContactTest.java @@ -17,9 +17,9 @@ public class ClientContactTest { @Test public void serializeToJSON() throws Exception { byte[] token = Util.getContactToken("+14152222222"); - ClientContact contact = new ClientContact(token, null, false); - ClientContact contactWithRelay = new ClientContact(token, "whisper", false); - ClientContact contactWithRelaySms = new ClientContact(token, "whisper", true ); + ClientContact contact = new ClientContact(token, null); + ClientContact contactWithRelay = new ClientContact(token, "whisper"); + ClientContact contactWithRelaySms = new ClientContact(token, "whisper"); assertThat("Basic Contact Serialization works", asJson(contact), @@ -28,19 +28,15 @@ public class ClientContactTest { assertThat("Contact Relay Serialization works", asJson(contactWithRelay), is(equalTo(jsonFixture("fixtures/contact.relay.json")))); - - assertThat("Contact Relay+SMS Serialization works", - asJson(contactWithRelaySms), - is(equalTo(jsonFixture("fixtures/contact.relay.sms.json")))); } @Test public void deserializeFromJSON() throws Exception { ClientContact contact = new ClientContact(Util.getContactToken("+14152222222"), - "whisper", true); + "whisper"); assertThat("a ClientContact can be deserialized from JSON", - fromJson(jsonFixture("fixtures/contact.relay.sms.json"), ClientContact.class), + fromJson(jsonFixture("fixtures/contact.relay.json"), ClientContact.class), is(contact)); } diff --git a/src/test/java/org/whispersystems/textsecuregcm/tests/entities/PreKeyTest.java b/src/test/java/org/whispersystems/textsecuregcm/tests/entities/PreKeyTest.java index b23698141..a77ef3ffb 100644 --- a/src/test/java/org/whispersystems/textsecuregcm/tests/entities/PreKeyTest.java +++ b/src/test/java/org/whispersystems/textsecuregcm/tests/entities/PreKeyTest.java @@ -26,10 +26,10 @@ public class PreKeyTest { @Test public void deserializeFromJSONV() throws Exception { ClientContact contact = new ClientContact(Util.getContactToken("+14152222222"), - "whisper", true); + "whisper"); assertThat("a ClientContact can be deserialized from JSON", - fromJson(jsonFixture("fixtures/contact.relay.sms.json"), ClientContact.class), + fromJson(jsonFixture("fixtures/contact.relay.json"), ClientContact.class), is(contact)); } diff --git a/src/test/resources/fixtures/contact.relay.sms.json b/src/test/resources/fixtures/contact.relay.sms.json deleted file mode 100644 index 4afe626c4..000000000 --- a/src/test/resources/fixtures/contact.relay.sms.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "relay" : "whisper", - "supportsSms" : true, - "token" : "BQVVHxMt5zAFXA" -} \ No newline at end of file