From eaa4c318e35a73cf3b18e0642bb69784f58aea95 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Tue, 7 Dec 2021 16:11:51 -0500 Subject: [PATCH] Add usernames to `whoami` and account creation responses --- .../textsecuregcm/controllers/AccountController.java | 2 ++ .../entities/AccountCreationResult.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index cfec6b46e..2d7f120d4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -391,6 +391,7 @@ public class AccountController { return new AccountCreationResult(account.getUuid(), account.getNumber(), account.getPhoneNumberIdentifier(), + account.getUsername().orElse(null), existingAccount.map(Account::isStorageSupported).orElse(false)); } @@ -605,6 +606,7 @@ public class AccountController { return new AccountCreationResult(auth.getAccount().getUuid(), auth.getAccount().getNumber(), auth.getAccount().getPhoneNumberIdentifier(), + auth.getAccount().getUsername().orElse(null), auth.getAccount().isStorageSupported()); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java index b0340641c..2e53b978d 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java @@ -8,6 +8,7 @@ package org.whispersystems.textsecuregcm.entities; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import javax.annotation.Nullable; import java.util.UUID; public class AccountCreationResult { @@ -15,6 +16,10 @@ public class AccountCreationResult { private final UUID uuid; private final String number; private final UUID pni; + + @Nullable + private final String username; + private final boolean storageCapable; @JsonCreator @@ -22,11 +27,13 @@ public class AccountCreationResult { @JsonProperty("uuid") final UUID uuid, @JsonProperty("number") final String number, @JsonProperty("pni") final UUID pni, + @JsonProperty("username") @Nullable final String username, @JsonProperty("storageCapable") final boolean storageCapable) { this.uuid = uuid; this.number = number; this.pni = pni; + this.username = username; this.storageCapable = storageCapable; } @@ -42,6 +49,11 @@ public class AccountCreationResult { return pni; } + @Nullable + public String getUsername() { + return username; + } + public boolean isStorageCapable() { return storageCapable; }