Skip to content

Commit

Permalink
return user's own username link handle in /whoami response
Browse files Browse the repository at this point in the history
  • Loading branch information
jkt-signal authored Sep 23, 2024
1 parent befcdf5 commit 2d184b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private AccountIdentityResponse buildAccountIdentityResponse(AccountAndAuthentic
auth.getAccount().getNumber(),
auth.getAccount().getPhoneNumberIdentifier(),
auth.getAccount().getUsernameHash().filter(h -> h.length > 0).orElse(null),
auth.getAccount().getUsernameLinkHandle(),
auth.getAccount().isStorageSupported());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public AccountIdentityResponse changeNumber(@Mutable @Auth final AuthenticatedDe
updatedAccount.getNumber(),
updatedAccount.getPhoneNumberIdentifier(),
updatedAccount.getUsernameHash().orElse(null),
updatedAccount.getUsernameLinkHandle(),
updatedAccount.isStorageSupported());
} catch (MismatchedDevicesException e) {
throw new WebApplicationException(Response.status(409)
Expand Down Expand Up @@ -208,6 +209,7 @@ public AccountIdentityResponse distributePhoneNumberIdentityKeys(
updatedAccount.getNumber(),
updatedAccount.getPhoneNumberIdentifier(),
updatedAccount.getUsernameHash().orElse(null),
updatedAccount.getUsernameLinkHandle(),
updatedAccount.isStorageSupported());
} catch (MismatchedDevicesException e) {
throw new WebApplicationException(Response.status(409)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public AccountIdentityResponse register(
account.getNumber(),
account.getPhoneNumberIdentifier(),
account.getUsernameHash().orElse(null),
account.getUsernameLinkHandle(),
existingAccount.map(Account::isStorageSupported).orElse(false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

0 comments on commit 2d184b1

Please sign in to comment.