From 7df978390fa7c6f93d0a7019a6a3083429df5b76 Mon Sep 17 00:00:00 2001 From: ravi-signal <99042880+ravi-signal@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:59:09 -0500 Subject: [PATCH] Add playProductId to backup level configuration --- .../configuration/SubscriptionLevelConfiguration.java | 1 + .../textsecuregcm/controllers/SubscriptionController.java | 8 +++++--- .../controllers/SubscriptionControllerTest.java | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionLevelConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionLevelConfiguration.java index 0bac40303..bc89a0828 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionLevelConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/SubscriptionLevelConfiguration.java @@ -29,6 +29,7 @@ public sealed interface SubscriptionLevelConfiguration permits } record Backup( + @JsonProperty("playProductId") @NotEmpty String playProductId, @JsonProperty("prices") @Valid Map<@NotEmpty String, @NotNull @Valid SubscriptionPriceConfiguration> prices) implements SubscriptionLevelConfiguration {} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java index 242d1cb6a..f3e73b208 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java @@ -210,7 +210,7 @@ public class SubscriptionController { .entrySet().stream() .collect(Collectors.toMap( e -> String.valueOf(e.getKey()), - ignored -> new BackupLevelConfiguration(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES))); + e -> new BackupLevelConfiguration(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES, e.getValue().playProductId()))); return new GetSubscriptionConfigurationResponse(buildCurrencyConfiguration(), donationLevels, new BackupConfiguration(backupLevels, subscriptionConfiguration.getbackupFreeTierMediaDuration().toDays()), @@ -476,12 +476,14 @@ public class SubscriptionController { @Schema(description = "A map of numeric backup level IDs to level-specific backup configuration") Map levels, @Schema(description = "The number of days of media a free tier backup user gets") - long backupFreeTierMediaDays) {} + long freeTierMediaDays) {} @Schema(description = "Configuration for a backup level - use to present appropriate client interfaces") public record BackupLevelConfiguration( @Schema(description = "The amount of media storage in bytes that a paying subscriber may store") - long storageAllowanceBytes) {} + long storageAllowanceBytes, + @Schema(description = "The play billing productID associated with this backup level") + String playProductId) {} @GET @Path("/configuration") diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java index e373c5cf6..89a6a668d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java @@ -1107,8 +1107,9 @@ class SubscriptionControllerTest { assertThat(response.backup().levels()).containsOnlyKeys("201").extractingByKey("201").satisfies(configuration -> { assertThat(configuration.storageAllowanceBytes()).isEqualTo(BackupManager.MAX_TOTAL_BACKUP_MEDIA_BYTES); + assertThat(configuration.playProductId()).isEqualTo("testPlayProductId"); }); - assertThat(response.backup().backupFreeTierMediaDays()).isEqualTo(30); + assertThat(response.backup().freeTierMediaDays()).isEqualTo(30); // check the badge vs purchasable badge fields // subscription levels are Badge, while one-time levels are PurchasableBadge, which adds `duration` @@ -1165,6 +1166,7 @@ class SubscriptionControllerTest { backupFreeTierMediaDuration: P30D backupLevels: 201: + playProductId: testPlayProductId prices: usd: amount: '5'