Convert `UserCapabilities` to a record
This commit is contained in:
parent
d138fa45df
commit
a60450d931
|
@ -8,7 +8,14 @@ package org.whispersystems.textsecuregcm.entities;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
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) {
|
public static UserCapabilities createForAccount(Account account) {
|
||||||
return new UserCapabilities(
|
return new UserCapabilities(
|
||||||
|
@ -20,72 +27,4 @@ public class UserCapabilities {
|
||||||
account.isGiftBadgesSupported(),
|
account.isGiftBadgesSupported(),
|
||||||
false); // Hardcode to false until all clients support the flow
|
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; }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,9 +392,9 @@ class ProfileControllerTest {
|
||||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||||
.get(BaseProfileResponse.class);
|
.get(BaseProfileResponse.class);
|
||||||
|
|
||||||
assertThat(profile.getCapabilities().isGv1Migration()).isTrue();
|
assertThat(profile.getCapabilities().gv1Migration()).isTrue();
|
||||||
assertThat(profile.getCapabilities().isSenderKey()).isTrue();
|
assertThat(profile.getCapabilities().senderKey()).isTrue();
|
||||||
assertThat(profile.getCapabilities().isAnnouncementGroup()).isTrue();
|
assertThat(profile.getCapabilities().announcementGroup()).isTrue();
|
||||||
|
|
||||||
profile = resources
|
profile = resources
|
||||||
.getJerseyTest()
|
.getJerseyTest()
|
||||||
|
@ -403,9 +403,9 @@ class ProfileControllerTest {
|
||||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID_TWO, AuthHelper.VALID_PASSWORD_TWO))
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID_TWO, AuthHelper.VALID_PASSWORD_TWO))
|
||||||
.get(BaseProfileResponse.class);
|
.get(BaseProfileResponse.class);
|
||||||
|
|
||||||
assertThat(profile.getCapabilities().isGv1Migration()).isTrue();
|
assertThat(profile.getCapabilities().gv1Migration()).isTrue();
|
||||||
assertThat(profile.getCapabilities().isSenderKey()).isFalse();
|
assertThat(profile.getCapabilities().senderKey()).isFalse();
|
||||||
assertThat(profile.getCapabilities().isAnnouncementGroup()).isFalse();
|
assertThat(profile.getCapabilities().announcementGroup()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -747,7 +747,7 @@ class ProfileControllerTest {
|
||||||
assertThat(profile.getAbout()).isEqualTo("about");
|
assertThat(profile.getAbout()).isEqualTo("about");
|
||||||
assertThat(profile.getAboutEmoji()).isEqualTo("emoji");
|
assertThat(profile.getAboutEmoji()).isEqualTo("emoji");
|
||||||
assertThat(profile.getAvatar()).isEqualTo("profiles/validavatar");
|
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().getUuid()).isEqualTo(AuthHelper.VALID_UUID_TWO);
|
||||||
assertThat(profile.getBaseProfileResponse().getBadges()).hasSize(1).element(0).has(new Condition<>(
|
assertThat(profile.getBaseProfileResponse().getBadges()).hasSize(1).element(0).has(new Condition<>(
|
||||||
badge -> "Test Badge".equals(badge.getName()), "has badge with expected name"));
|
badge -> "Test Badge".equals(badge.getName()), "has badge with expected name"));
|
||||||
|
|
Loading…
Reference in New Issue