diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index 1509ffc16..385a49833 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -10,6 +10,7 @@ import io.dropwizard.auth.Auth; import java.security.SecureRandom; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -244,17 +245,18 @@ public class ProfileController { Optional credential = getProfileCredential(credentialRequest, profile, uuid); return Optional.of(new Profile(name, - about, - aboutEmoji, - avatar, - paymentAddress, - accountProfile.get().getIdentityKey(), - UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), - accountProfile.get().isUnrestrictedUnidentifiedAccess(), - UserCapabilities.createForAccount(accountProfile.get()), - username.orElse(null), - null, - credential.orElse(null))); + about, + aboutEmoji, + avatar, + paymentAddress, + accountProfile.get().getIdentityKey(), + UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), + accountProfile.get().isUnrestrictedUnidentifiedAccess(), + UserCapabilities.createForAccount(accountProfile.get()), + username.orElse(null), + null, + List.of(), + credential.orElse(null))); } catch (InvalidInputException e) { logger.info("Bad profile request", e); throw new WebApplicationException(Response.Status.BAD_REQUEST); @@ -284,18 +286,20 @@ public class ProfileController { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } - return new Profile(accountProfile.get().getProfileName(), - null, - null, - accountProfile.get().getAvatar(), - null, - accountProfile.get().getIdentityKey(), - UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), - accountProfile.get().isUnrestrictedUnidentifiedAccess(), - UserCapabilities.createForAccount(accountProfile.get()), - username, - accountProfile.get().getUuid(), - null); + return new Profile( + accountProfile.get().getProfileName(), + null, + null, + accountProfile.get().getAvatar(), + null, + accountProfile.get().getIdentityKey(), + UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), + accountProfile.get().isUnrestrictedUnidentifiedAccess(), + UserCapabilities.createForAccount(accountProfile.get()), + username, + accountProfile.get().getUuid(), + List.of(), + null); } private Optional getProfileCredential(Optional encodedProfileCredentialRequest, @@ -355,18 +359,20 @@ public class ProfileController { Optional username = usernamesManager.get(accountProfile.get().getUuid()); - return new Profile(accountProfile.get().getProfileName(), - null, - null, - accountProfile.get().getAvatar(), - null, - accountProfile.get().getIdentityKey(), - UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), - accountProfile.get().isUnrestrictedUnidentifiedAccess(), - UserCapabilities.createForAccount(accountProfile.get()), - username.orElse(null), - null, - null); + return new Profile( + accountProfile.get().getProfileName(), + null, + null, + accountProfile.get().getAvatar(), + null, + accountProfile.get().getIdentityKey(), + UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()), + accountProfile.get().isUnrestrictedUnidentifiedAccess(), + UserCapabilities.createForAccount(accountProfile.get()), + username.orElse(null), + null, + List.of(), + null); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java new file mode 100644 index 000000000..d6fd22cc7 --- /dev/null +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Badge.java @@ -0,0 +1,38 @@ +/* + * Copyright 2021 Signal Messenger, LLC + * SPDX-License-Identifier: AGPL-3.0-only + */ + +package org.whispersystems.textsecuregcm.entities; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.net.URL; + +public class Badge { + private URL imageUrl; + private String name; + private String description; + + @JsonCreator + public Badge( + @JsonProperty("imageUrl") final URL imageUrl, + @JsonProperty("name") final String name, + @JsonProperty("description") final String description) { + this.imageUrl = imageUrl; + this.name = name; + this.description = description; + } + + public URL getImageUrl() { + return imageUrl; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/Profile.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Profile.java index 371188d4f..edb31eb6a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/Profile.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/Profile.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.annotations.VisibleForTesting; +import java.util.List; import java.util.UUID; import org.signal.zkgroup.profiles.ProfileKeyCredentialResponse; @@ -47,6 +48,9 @@ public class Profile { @JsonProperty private UUID uuid; + @JsonProperty + private List badges; + @JsonProperty @JsonSerialize(using = ProfileKeyCredentialResponseAdapter.Serializing.class) @JsonDeserialize(using = ProfileKeyCredentialResponseAdapter.Deserializing.class) @@ -57,7 +61,7 @@ public class Profile { public Profile( String name, String about, String aboutEmoji, String avatar, String paymentAddress, String identityKey, String unidentifiedAccess, boolean unrestrictedUnidentifiedAccess, UserCapabilities capabilities, String username, - UUID uuid, ProfileKeyCredentialResponse credential) + UUID uuid, final List badges, ProfileKeyCredentialResponse credential) { this.name = name; this.about = about; @@ -70,6 +74,7 @@ public class Profile { this.capabilities = capabilities; this.username = username; this.uuid = uuid; + this.badges = badges; this.credential = credential; } @@ -124,4 +129,8 @@ public class Profile { public UUID getUuid() { return uuid; } + + public List getBadges() { + return badges; + } }