Remove extraneous account fetch in POST /v1/donation/redeem-receipt

This commit is contained in:
Chris Eager 2025-04-15 13:44:28 -05:00 committed by Chris Eager
parent 57be4d798b
commit 7cac6f6f72
1 changed files with 6 additions and 8 deletions

View File

@ -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());