From 8cb9c60a3c2bee9f7a855c4697608bb6f46d6093 Mon Sep 17 00:00:00 2001 From: Ravi Khadiwala Date: Tue, 17 Sep 2024 13:02:22 -0500 Subject: [PATCH] Relax configured currency checks --- .../configuration/SubscriptionConfiguration.java | 10 ++++++---- service/src/test/resources/config/test.yml | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionConfiguration.java index e97fc347c..3bcb20824 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionConfiguration.java @@ -104,11 +104,13 @@ public boolean areLevelConstraintsSatisfied() { @JsonIgnore @ValidationMethod(message = "has a mismatch between the levels supported currencies") public boolean isCurrencyListSameAcrossAllLevels() { - final Map subscriptionLevels = Stream - .concat(donationLevels.entrySet().stream(), backupLevels.entrySet().stream()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + return isCurrencyListSameAccrossLevelConfigurations(donationLevels) + && isCurrencyListSameAccrossLevelConfigurations(backupLevels); + } - Optional any = subscriptionLevels.values().stream().findAny(); + private static boolean isCurrencyListSameAccrossLevelConfigurations( + Map subscriptionLevels) { + Optional any = subscriptionLevels.values().stream().findAny(); if (any.isEmpty()) { return true; } diff --git a/service/src/test/resources/config/test.yml b/service/src/test/resources/config/test.yml index c062e3dd3..911b905b5 100644 --- a/service/src/test/resources/config/test.yml +++ b/service/src/test/resources/config/test.yml @@ -367,6 +367,10 @@ subscription: # configuration for Stripe subscriptions backupExpiration: P30D backupGracePeriod: P15D backupFreeTierMediaDuration: P30D + backupLevels: + 201: + playProductId: EXAMPLE + prices: {} levels: 500: badge: EXAMPLE