diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java index d7ca26699..ed315bf37 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/UserCapabilities.java @@ -8,7 +8,14 @@ package org.whispersystems.textsecuregcm.entities; import com.fasterxml.jackson.annotation.JsonProperty; import org.whispersystems.textsecuregcm.storage.Account; -public class UserCapabilities { +public record UserCapabilities( + @JsonProperty("gv1-migration") boolean gv1Migration, + boolean senderKey, + boolean announcementGroup, + boolean changeNumber, + boolean stories, + boolean giftBadges, + boolean paymentActivation) { public static UserCapabilities createForAccount(Account account) { return new UserCapabilities( @@ -20,72 +27,4 @@ public class UserCapabilities { account.isGiftBadgesSupported(), false); // Hardcode to false until all clients support the flow } - - @JsonProperty("gv1-migration") - private boolean gv1Migration; - - @JsonProperty - private boolean senderKey; - - @JsonProperty - private boolean announcementGroup; - - @JsonProperty - private boolean changeNumber; - - @JsonProperty - private boolean stories; - - @JsonProperty - private boolean giftBadges; - - @JsonProperty - private boolean paymentActivation; - - public UserCapabilities() { - } - - public UserCapabilities( - boolean gv1Migration, - final boolean senderKey, - final boolean announcementGroup, - final boolean changeNumber, - final boolean stories, - final boolean giftBadges, - final boolean paymentActivation) { - - this.gv1Migration = gv1Migration; - this.senderKey = senderKey; - this.announcementGroup = announcementGroup; - this.changeNumber = changeNumber; - this.stories = stories; - this.giftBadges = giftBadges; - this.paymentActivation = paymentActivation; - } - - public boolean isGv1Migration() { - return gv1Migration; - } - - public boolean isSenderKey() { - return senderKey; - } - - public boolean isAnnouncementGroup() { - return announcementGroup; - } - - public boolean isChangeNumber() { - return changeNumber; - } - - public boolean isStories() { - return stories; - } - - public boolean isGiftBadges() { - return giftBadges; - } - - public boolean isPaymentActivation() { return paymentActivation; } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/ProfileControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/ProfileControllerTest.java index 16a8db9b5..2d2cace83 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/ProfileControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/ProfileControllerTest.java @@ -392,9 +392,9 @@ class ProfileControllerTest { .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD)) .get(BaseProfileResponse.class); - assertThat(profile.getCapabilities().isGv1Migration()).isTrue(); - assertThat(profile.getCapabilities().isSenderKey()).isTrue(); - assertThat(profile.getCapabilities().isAnnouncementGroup()).isTrue(); + assertThat(profile.getCapabilities().gv1Migration()).isTrue(); + assertThat(profile.getCapabilities().senderKey()).isTrue(); + assertThat(profile.getCapabilities().announcementGroup()).isTrue(); profile = resources .getJerseyTest() @@ -403,9 +403,9 @@ class ProfileControllerTest { .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID_TWO, AuthHelper.VALID_PASSWORD_TWO)) .get(BaseProfileResponse.class); - assertThat(profile.getCapabilities().isGv1Migration()).isTrue(); - assertThat(profile.getCapabilities().isSenderKey()).isFalse(); - assertThat(profile.getCapabilities().isAnnouncementGroup()).isFalse(); + assertThat(profile.getCapabilities().gv1Migration()).isTrue(); + assertThat(profile.getCapabilities().senderKey()).isFalse(); + assertThat(profile.getCapabilities().announcementGroup()).isFalse(); } @Test @@ -747,7 +747,7 @@ class ProfileControllerTest { assertThat(profile.getAbout()).isEqualTo("about"); assertThat(profile.getAboutEmoji()).isEqualTo("emoji"); assertThat(profile.getAvatar()).isEqualTo("profiles/validavatar"); - assertThat(profile.getBaseProfileResponse().getCapabilities().isGv1Migration()).isTrue(); + assertThat(profile.getBaseProfileResponse().getCapabilities().gv1Migration()).isTrue(); assertThat(profile.getBaseProfileResponse().getUuid()).isEqualTo(AuthHelper.VALID_UUID_TWO); assertThat(profile.getBaseProfileResponse().getBadges()).hasSize(1).element(0).has(new Condition<>( badge -> "Test Badge".equals(badge.getName()), "has badge with expected name"));