Improve handling of network timeouts for donor badges.

This commit is contained in:
Alex Hart
2021-11-05 15:21:27 -03:00
committed by Greyson Parrelli
parent c4164b17a2
commit 482a10de02
9 changed files with 74 additions and 44 deletions

View File

@@ -125,10 +125,18 @@ public class DonationsService {
* @param level The new level to subscribe to
* @param currencyCode The currencyCode the user is using for payment
* @param idempotencyKey url-safe-base64-encoded random 16-byte value (see description)
* @param mutex A mutex to lock on to avoid a situation where this subscription update happens *as* we are trying to get a credential receipt.
*/
public Single<ServiceResponse<EmptyResponse>> updateSubscriptionLevel(SubscriberId subscriberId, String level, String currencyCode, String idempotencyKey) {
public Single<ServiceResponse<EmptyResponse>> updateSubscriptionLevel(SubscriberId subscriberId,
String level,
String currencyCode,
String idempotencyKey,
Object mutex
) {
return createServiceResponse(() -> {
pushServiceSocket.updateSubscriptionLevel(subscriberId.serialize(), level, currencyCode, idempotencyKey);
synchronized(mutex) {
pushServiceSocket.updateSubscriptionLevel(subscriberId.serialize(), level, currencyCode, idempotencyKey);
}
return new Pair<>(EmptyResponse.INSTANCE, 200);
});
}