diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java b/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java index 52be05e45..fe8120924 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java @@ -110,6 +110,8 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter { configuration.getXhdpi(), configuration.getXxhdpi(), configuration.getXxxhdpi(), + configuration.getLowDetailSvg(), + configuration.getHighDetailSvg(), accountBadge.getExpiration(), accountBadge.isVisible()); }) @@ -128,6 +130,8 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter { configuration.getXhdpi(), configuration.getXxhdpi(), configuration.getXxxhdpi(), + configuration.getLowDetailSvg(), + configuration.getHighDetailSvg(), now.plus(Duration.ofDays(1)), true); }).collect(Collectors.toList())); @@ -146,12 +150,14 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter { final String xhdpi, final String xxhdpi, final String xxxhdpi, + final String lsvg, + final String hsvg, final Instant expiration, final boolean visible) { if (isSelf) { - return new SelfBadge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, expiration, visible); + return new SelfBadge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg, expiration, visible); } else { - return new Badge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); + return new Badge(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg); } } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/BadgeConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/BadgeConfiguration.java index 234277cc6..e01614f6a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/BadgeConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/BadgeConfiguration.java @@ -20,6 +20,8 @@ public class BadgeConfiguration { private final String xhdpi; private final String xxhdpi; private final String xxxhdpi; + private final String lowDetailSvg; + private final String highDetailSvg; @JsonCreator public BadgeConfiguration( @@ -30,7 +32,9 @@ public class BadgeConfiguration { @JsonProperty("hdpi") final String hdpi, @JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xxhdpi") final String xxhdpi, - @JsonProperty("xxxhdpi") final String xxxhdpi) { + @JsonProperty("xxxhdpi") final String xxxhdpi, + @JsonProperty("lowDetailSvg") final String lowDetailSvg, + @JsonProperty("highDetailSvg") final String highDetailSvg) { this.id = id; this.category = category; this.ldpi = ldpi; @@ -39,6 +43,8 @@ public class BadgeConfiguration { this.xhdpi = xhdpi; this.xxhdpi = xxhdpi; this.xxxhdpi = xxxhdpi; + this.lowDetailSvg = lowDetailSvg; + this.highDetailSvg = highDetailSvg; } @NotEmpty @@ -51,30 +57,46 @@ public class BadgeConfiguration { return category; } + @NotEmpty public String getLdpi() { return ldpi; } + @NotEmpty public String getMdpi() { return mdpi; } + @NotEmpty public String getHdpi() { return hdpi; } + @NotEmpty public String getXhdpi() { return xhdpi; } + @NotEmpty public String getXxhdpi() { return xxhdpi; } + @NotEmpty public String getXxxhdpi() { return xxxhdpi; } + @NotEmpty + public String getLowDetailSvg() { + return lowDetailSvg; + } + + @NotEmpty + public String getHighDetailSvg() { + return highDetailSvg; + } + public boolean isTestBadge() { return CATEGORY_TESTING.equals(category); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java index f294c0e78..3a824ea67 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java @@ -20,6 +20,8 @@ public class Badge { private final String xhdpi; private final String xxhdpi; private final String xxxhdpi; + private final String lsvg; + private final String hsvg; @JsonCreator public Badge( @@ -32,7 +34,9 @@ public class Badge { @JsonProperty("hdpi") final String hdpi, @JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xxhdpi") final String xxhdpi, - @JsonProperty("xxxhdpi") final String xxxhdpi) { + @JsonProperty("xxxhdpi") final String xxxhdpi, + @JsonProperty("lsvg") final String lsvg, + @JsonProperty("hsvg") final String hsvg) { this.id = id; this.category = category; this.name = name; @@ -43,6 +47,8 @@ public class Badge { this.xhdpi = xhdpi; this.xxhdpi = xxhdpi; this.xxxhdpi = xxxhdpi; + this.lsvg = lsvg; + this.hsvg = hsvg; } public String getId() { @@ -85,6 +91,14 @@ public class Badge { return xxxhdpi; } + public String getLsvg() { + return lsvg; + } + + public String getHsvg() { + return hsvg; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -94,16 +108,34 @@ public class Badge { return false; } Badge badge = (Badge) o; - return Objects.equals(id, badge.id) && Objects.equals(category, - badge.category) && Objects.equals(name, badge.name) && Objects.equals( - description, badge.description) && Objects.equals(ldpi, badge.ldpi) - && Objects.equals(mdpi, badge.mdpi) && Objects.equals(hdpi, badge.hdpi) - && Objects.equals(xhdpi, badge.xhdpi) && Objects.equals(xxhdpi, - badge.xxhdpi) && Objects.equals(xxxhdpi, badge.xxxhdpi); + return Objects.equals(id, badge.id) + && Objects.equals(category, badge.category) + && Objects.equals(name, badge.name) + && Objects.equals(description, badge.description) + && Objects.equals(ldpi, badge.ldpi) + && Objects.equals(mdpi, badge.mdpi) + && Objects.equals(hdpi, badge.hdpi) + && Objects.equals(xhdpi, badge.xhdpi) + && Objects.equals(xxhdpi, badge.xxhdpi) + && Objects.equals(xxxhdpi, badge.xxxhdpi) + && Objects.equals(lsvg, badge.lsvg) + && Objects.equals(hsvg, badge.hsvg); } @Override public int hashCode() { - return Objects.hash(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); + return Objects.hash( + id, + category, + name, + description, + ldpi, + mdpi, + hdpi, + xhdpi, + xxhdpi, + xxxhdpi, + lsvg, + hsvg); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/SelfBadge.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/SelfBadge.java index 8503ab89e..bffce49ad 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/SelfBadge.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/SelfBadge.java @@ -27,9 +27,11 @@ public class SelfBadge extends Badge { @JsonProperty("xhdpi") final String xhdpi, @JsonProperty("xxhdpi") final String xxhdpi, @JsonProperty("xxxhdpi") final String xxxhdpi, + @JsonProperty("lsvg") final String lsvg, + @JsonProperty("hsvg") final String hsvg, final Instant expiration, final boolean visible) { - super(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi); + super(id, category, name, description, ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi, lsvg, hsvg); this.expiration = expiration; this.visible = visible; } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java index 0adf49c60..201da05a6 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java @@ -63,7 +63,7 @@ public class ConfiguredProfileBadgeConverterTest { } private static BadgeConfiguration newBadge(int i) { - return new BadgeConfiguration(idFor(i), "other", "l", "m", "h", "x", "xx", "xxx"); + return new BadgeConfiguration(idFor(i), "other", "l", "m", "h", "x", "xx", "xxx", "s", "S"); } private BadgesConfiguration createBadges(int count) { @@ -133,15 +133,15 @@ public class ConfiguredProfileBadgeConverterTest { arguments(idFor(0), expired, false, false, null), arguments(idFor(0), notExpired, false, false, null), arguments(idFor(0), expired, true, false, null), - arguments(idFor(0), notExpired, true, false, new Badge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx")), + arguments(idFor(0), notExpired, true, false, new Badge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S")), arguments(idFor(1), expired, false, false, null), arguments(idFor(1), notExpired, false, false, null), arguments(idFor(1), expired, true, false, null), arguments(idFor(1), notExpired, true, false, null), arguments(idFor(0), expired, false, true, null), - arguments(idFor(0), notExpired, false, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", notExpired, false)), + arguments(idFor(0), notExpired, false, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S", notExpired, false)), arguments(idFor(0), expired, true, true, null), - arguments(idFor(0), notExpired, true, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", notExpired, true)), + arguments(idFor(0), notExpired, true, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), "l", "m", "h", "x", "xx", "xxx", "s", "S", notExpired, true)), arguments(idFor(1), expired, false, true, null), arguments(idFor(1), notExpired, false, true, null), arguments(idFor(1), expired, true, true, null), diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java index bb6658b16..7f5cf084c 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java @@ -108,13 +108,13 @@ class ProfileControllerTest { usernamesManager, dynamicConfigurationManager, (acceptableLanguages, accountBadges, isSelf) -> List.of( - new Badge("TEST", "other", "Test Badge", "This badge is in unit tests.", "l", "m", "h", "x", "xx", "xxx") + new Badge("TEST", "other", "Test Badge", "This badge is in unit tests.", "l", "m", "h", "x", "xx", "xxx", "s", "S") ), new BadgesConfiguration(List.of( - new BadgeConfiguration("TEST", "other", "l", "m", "h", "x", "xx", "xxx"), - new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx"), - new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx"), - new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx") + new BadgeConfiguration("TEST", "other", "l", "m", "h", "x", "xx", "xxx", "s", "S"), + new BadgeConfiguration("TEST1", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"), + new BadgeConfiguration("TEST2", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S"), + new BadgeConfiguration("TEST3", "testing", "l", "m", "h", "x", "xx", "xxx", "s", "S") ), List.of("TEST1")), s3client, postPolicyGenerator,