Skip to content

Commit

Permalink
don't make empty transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jkt-signal authored Nov 2, 2023
1 parent b081814 commit d47ff9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public CompletableFuture<Void> store(final UUID identifier, final byte deviceId,
* @return a future that completes once all keys have been stored
*/
public CompletableFuture<Void> store(final UUID identifier, final Map<Byte, K> signedPreKeysByDeviceId) {
if (signedPreKeysByDeviceId.isEmpty()) {
return CompletableFuture.completedFuture(null);
}

final Timer.Sample sample = Timer.start();

return dynamoDbAsyncClient.transactWriteItems(TransactWriteItemsRequest.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ void testStorePqLastResort() {
"storing new last-resort keys should leave untouched ones alone");
assertEquals(4L, keysManager.getLastResort(ACCOUNT_UUID, deviceId3).join().get().keyId(),
"storing new last-resort keys should overwrite old ones");

keysManager.storePqLastResort(ACCOUNT_UUID, Map.of()).join();
assertEquals(3, keysManager.getPqEnabledDevices(ACCOUNT_UUID).join().size(), "storing zero last-resort keys should be a no-op");
}

@Test
Expand Down

0 comments on commit d47ff9b

Please sign in to comment.