From 34e21b9f7b38f6e4688613dc40d89f822a73dc3e Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 15 Sep 2021 16:44:42 -0500 Subject: [PATCH] Change name to id on AccountBadge This makes it distinct from the localized name field on the Badge entity that is returned. --- .../badges/ConfiguredProfileBadgeConverter.java | 8 ++++---- .../textsecuregcm/storage/Account.java | 2 +- .../textsecuregcm/storage/AccountBadge.java | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) 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 41cb2af71..275656d19 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverter.java @@ -89,10 +89,10 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter { return accountBadges.stream() .filter(accountBadge -> accountBadge.isVisible() && now.isBefore(accountBadge.getExpiration()) - && knownBadges.containsKey(accountBadge.getName())) - .map(accountBadge -> new Badge(knownBadges.get(accountBadge.getName()).getImageUrl(), - resourceBundle.getString(accountBadge.getName() + "_name"), - resourceBundle.getString(accountBadge.getName() + "_description"))) + && knownBadges.containsKey(accountBadge.getId())) + .map(accountBadge -> new Badge(knownBadges.get(accountBadge.getId()).getImageUrl(), + resourceBundle.getString(accountBadge.getId() + "_name"), + resourceBundle.getString(accountBadge.getId() + "_description"))) .collect(Collectors.toList()); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java index b7137b288..bfed35b39 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java @@ -331,7 +331,7 @@ public class Account { public void removeBadge(String name) { requireNotStale(); - badges.removeIf(accountBadge -> Objects.equals(accountBadge.getName(), name)); + badges.removeIf(accountBadge -> Objects.equals(accountBadge.getId(), name)); purgeStaleBadges(); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountBadge.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountBadge.java index 4de2547c1..16c7bad03 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountBadge.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountBadge.java @@ -12,22 +12,22 @@ import java.util.Objects; public class AccountBadge { - private final String name; + private final String id; private final Instant expiration; private final boolean visible; @JsonCreator public AccountBadge( - @JsonProperty("name") String name, + @JsonProperty("id") String id, @JsonProperty("expiration") Instant expiration, @JsonProperty("visible") boolean visible) { - this.name = name; + this.id = id; this.expiration = expiration; this.visible = visible; } - public String getName() { - return name; + public String getId() { + return id; } public Instant getExpiration() { @@ -47,19 +47,19 @@ public class AccountBadge { return false; } AccountBadge that = (AccountBadge) o; - return visible == that.visible && Objects.equals(name, that.name) + return visible == that.visible && Objects.equals(id, that.id) && Objects.equals(expiration, that.expiration); } @Override public int hashCode() { - return Objects.hash(name, expiration, visible); + return Objects.hash(id, expiration, visible); } @Override public String toString() { return "AccountBadge{" + - "name='" + name + '\'' + + "id='" + id + '\'' + ", expiration=" + expiration + ", visible=" + visible + '}';