From 2d184b1ab69b0dc31bb12bcdff4a457738d4ef7b Mon Sep 17 00:00:00 2001 From: Jonathan Klabunde Tomer <125505367+jkt-signal@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:46:10 -0700 Subject: [PATCH] return user's own username link handle in /whoami response --- .../textsecuregcm/controllers/AccountController.java | 1 + .../textsecuregcm/controllers/AccountControllerV2.java | 2 ++ .../textsecuregcm/controllers/RegistrationController.java | 1 + .../textsecuregcm/entities/AccountIdentityResponse.java | 3 +++ 4 files changed, 7 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 e11522bfa..1fad99a91 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -252,6 +252,7 @@ public class AccountController { auth.getAccount().getNumber(), auth.getAccount().getPhoneNumberIdentifier(), auth.getAccount().getUsernameHash().filter(h -> h.length > 0).orElse(null), + auth.getAccount().getUsernameLinkHandle(), auth.getAccount().isStorageSupported()); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java index f278a9ed2..34cd4d182 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountControllerV2.java @@ -150,6 +150,7 @@ public class AccountControllerV2 { updatedAccount.getNumber(), updatedAccount.getPhoneNumberIdentifier(), updatedAccount.getUsernameHash().orElse(null), + updatedAccount.getUsernameLinkHandle(), updatedAccount.isStorageSupported()); } catch (MismatchedDevicesException e) { throw new WebApplicationException(Response.status(409) @@ -208,6 +209,7 @@ public class AccountControllerV2 { updatedAccount.getNumber(), updatedAccount.getPhoneNumberIdentifier(), updatedAccount.getUsernameHash().orElse(null), + updatedAccount.getUsernameLinkHandle(), updatedAccount.isStorageSupported()); } catch (MismatchedDevicesException e) { throw new WebApplicationException(Response.status(409) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java index 0f0ee854c..2bb4fa7f4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/RegistrationController.java @@ -170,6 +170,7 @@ public class RegistrationController { account.getNumber(), account.getPhoneNumberIdentifier(), account.getUsernameHash().orElse(null), + account.getUsernameLinkHandle(), existingAccount.map(Account::isStorageSupported).orElse(false)); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java index ec9e186aa..29c8ca44a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java @@ -27,6 +27,9 @@ public record AccountIdentityResponse( @JsonDeserialize(using = ByteArrayBase64UrlAdapter.Deserializing.class) @Nullable byte[] usernameHash, + @Schema(description="this account's username link handle, if set") + @Nullable UUID usernameLinkHandle, + @Schema(description="whether any of this account's devices support storage") boolean storageCapable) { }