From 7cac6f6f72164ae40e84dea693ed7e081ae6b356 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Tue, 15 Apr 2025 13:44:28 -0500 Subject: [PATCH] Remove extraneous account fetch in POST /v1/donation/redeem-receipt --- .../controllers/DonationController.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java index daf3d4898..0c10854d7 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DonationController.java @@ -104,14 +104,12 @@ public class DonationController { .type(MediaType.TEXT_PLAIN_TYPE).build()); } - return accountsManager.getByAccountIdentifierAsync(auth.getAccount().getUuid()) - .thenCompose(optionalAccount -> - optionalAccount.map(account -> accountsManager.updateAsync(account, a -> { - a.addBadge(clock, new AccountBadge(badgeId, receiptExpiration, request.isVisible())); - if (request.isPrimary()) { - a.makeBadgePrimaryIfExists(clock, badgeId); - } - })).orElse(CompletableFuture.completedFuture(null))) + return accountsManager.updateAsync(auth.getAccount(), a -> { + a.addBadge(clock, new AccountBadge(badgeId, receiptExpiration, request.isVisible())); + if (request.isPrimary()) { + a.makeBadgePrimaryIfExists(clock, badgeId); + } + }) .thenApply(ignored -> Response.ok().build()); }); }).thenCompose(Function.identity());