Add usernames to `whoami` and account creation responses

This commit is contained in:
Jon Chambers 2021-12-07 16:11:51 -05:00 committed by Jon Chambers
parent 31373fd1ba
commit eaa4c318e3
2 changed files with 14 additions and 0 deletions

View File

@ -391,6 +391,7 @@ public class AccountController {
return new AccountCreationResult(account.getUuid(), return new AccountCreationResult(account.getUuid(),
account.getNumber(), account.getNumber(),
account.getPhoneNumberIdentifier(), account.getPhoneNumberIdentifier(),
account.getUsername().orElse(null),
existingAccount.map(Account::isStorageSupported).orElse(false)); existingAccount.map(Account::isStorageSupported).orElse(false));
} }
@ -605,6 +606,7 @@ public class AccountController {
return new AccountCreationResult(auth.getAccount().getUuid(), return new AccountCreationResult(auth.getAccount().getUuid(),
auth.getAccount().getNumber(), auth.getAccount().getNumber(),
auth.getAccount().getPhoneNumberIdentifier(), auth.getAccount().getPhoneNumberIdentifier(),
auth.getAccount().getUsername().orElse(null),
auth.getAccount().isStorageSupported()); auth.getAccount().isStorageSupported());
} }

View File

@ -8,6 +8,7 @@ package org.whispersystems.textsecuregcm.entities;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
public class AccountCreationResult { public class AccountCreationResult {
@ -15,6 +16,10 @@ public class AccountCreationResult {
private final UUID uuid; private final UUID uuid;
private final String number; private final String number;
private final UUID pni; private final UUID pni;
@Nullable
private final String username;
private final boolean storageCapable; private final boolean storageCapable;
@JsonCreator @JsonCreator
@ -22,11 +27,13 @@ public class AccountCreationResult {
@JsonProperty("uuid") final UUID uuid, @JsonProperty("uuid") final UUID uuid,
@JsonProperty("number") final String number, @JsonProperty("number") final String number,
@JsonProperty("pni") final UUID pni, @JsonProperty("pni") final UUID pni,
@JsonProperty("username") @Nullable final String username,
@JsonProperty("storageCapable") final boolean storageCapable) { @JsonProperty("storageCapable") final boolean storageCapable) {
this.uuid = uuid; this.uuid = uuid;
this.number = number; this.number = number;
this.pni = pni; this.pni = pni;
this.username = username;
this.storageCapable = storageCapable; this.storageCapable = storageCapable;
} }
@ -42,6 +49,11 @@ public class AccountCreationResult {
return pni; return pni;
} }
@Nullable
public String getUsername() {
return username;
}
public boolean isStorageCapable() { public boolean isStorageCapable() {
return storageCapable; return storageCapable;
} }