Handle multiple values with same ACI in deleted-accounts table

Co-authored-by: Chris Eager <79161849+eager-signal@users.noreply.github.com>
This commit is contained in:
Jonathan Klabunde Tomer 2024-11-22 15:11:27 -08:00 committed by GitHub
parent 739ed56b4c
commit 0cb6f662c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 5 deletions

View File

@ -1217,11 +1217,10 @@ public class Accounts extends AbstractDynamoDbStore {
return Optional.empty();
}
if (response.count() > 1) {
throw new RuntimeException("Impossible result: more than one phone number returned for UUID: " + uuid);
}
return Optional.ofNullable(response.items().get(0).get(DELETED_ACCOUNTS_KEY_ACCOUNT_E164).s());
return response.items().stream()
.map(item -> item.get(DELETED_ACCOUNTS_KEY_ACCOUNT_E164).s())
.filter(e164OrPni -> e164OrPni.startsWith("+"))
.findFirst();
}
public CompletableFuture<Void> delete(final UUID uuid, final List<TransactWriteItem> additionalWriteItems) {