Skip to content

Commit

Permalink
Make key-setting methods synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-signal committed Dec 13, 2023
1 parent f738bc9 commit 1167d0a
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.KeysManager;
import org.whispersystems.textsecuregcm.util.Util;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -110,7 +109,7 @@ public CompletableFuture<PreKeyCount> getStatus(@Auth final AuthenticatedAccount
@ApiResponse(responseCode = "401", description = "Account authentication check failed.")
@ApiResponse(responseCode = "403", description = "Attempt to change identity key from a non-primary device.")
@ApiResponse(responseCode = "422", description = "Invalid request format.")
public CompletableFuture<Response> setKeys(@Auth final DisabledPermittedAuthenticatedAccount disabledPermittedAuth,
public void setKeys(@Auth final DisabledPermittedAuthenticatedAccount disabledPermittedAuth,
@RequestBody @NotNull @Valid final SetKeysRequest setKeysRequest,

@Parameter(allowEmptyValue=true)
Expand Down Expand Up @@ -147,7 +146,7 @@ public CompletableFuture<Response> setKeys(@Auth final DisabledPermittedAuthenti
updateAccountFuture = CompletableFuture.completedFuture(account);
}

return updateAccountFuture.thenCompose(updatedAccount -> {
updateAccountFuture.thenCompose(updatedAccount -> {
final List<CompletableFuture<Void>> storeFutures = new ArrayList<>(3);

if (setKeysRequest.preKeys() != null && !setKeysRequest.preKeys().isEmpty()) {
Expand All @@ -165,7 +164,7 @@ public CompletableFuture<Response> setKeys(@Auth final DisabledPermittedAuthenti

return CompletableFuture.allOf(storeFutures.toArray(EMPTY_FUTURE_ARRAY));
})
.thenApply(Util.ASYNC_EMPTY_RESPONSE);
.join();
}

private void checkSignedPreKeySignatures(final SetKeysRequest setKeysRequest, final IdentityKey identityKey) {
Expand Down Expand Up @@ -292,14 +291,14 @@ public PreKeyResponse getDeviceKeys(@Auth Optional<AuthenticatedAccount> auth,
@ApiResponse(responseCode = "200", description = "Indicates that new prekey was successfully stored.")
@ApiResponse(responseCode = "401", description = "Account authentication check failed.")
@ApiResponse(responseCode = "422", description = "Invalid request format.")
public CompletableFuture<Response> setSignedKey(@Auth final AuthenticatedAccount auth,
public void setSignedKey(@Auth final AuthenticatedAccount auth,
@Valid final ECSignedPreKey signedPreKey,
@QueryParam("identity") @DefaultValue("aci") final IdentityType identityType) {

final UUID identifier = auth.getAccount().getIdentifier(identityType);
final byte deviceId = auth.getAuthenticatedDevice().getId();

return accounts.updateDeviceTransactionallyAsync(auth.getAccount(),
accounts.updateDeviceTransactionallyAsync(auth.getAccount(),
deviceId,
d -> {
switch (identityType) {
Expand All @@ -311,7 +310,7 @@ public CompletableFuture<Response> setSignedKey(@Auth final AuthenticatedAccount
.map(List::of)
.orElseGet(Collections::emptyList))
.toCompletableFuture()
.thenApply(Util.ASYNC_EMPTY_RESPONSE);
.join();
}

private List<Device> parseDeviceId(String deviceId, Account account) {
Expand Down

0 comments on commit 1167d0a

Please sign in to comment.