From f6471cf8f9c900f925b170ac84d12de43097a10a Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 27 Apr 2022 11:44:49 -0500 Subject: [PATCH] Add gift configuration source --- .../WhisperServerConfiguration.java | 10 +++++++++ .../configuration/GiftConfiguration.java | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 service/src/main/java/org/whispersystems/textsecuregcm/configuration/GiftConfiguration.java diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index 7cab05001..54d86ba31 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -29,6 +29,7 @@ import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguratio import org.whispersystems.textsecuregcm.configuration.DynamoDbTables; import org.whispersystems.textsecuregcm.configuration.GcmConfiguration; import org.whispersystems.textsecuregcm.configuration.GcpAttachmentsConfiguration; +import org.whispersystems.textsecuregcm.configuration.GiftConfiguration; import org.whispersystems.textsecuregcm.configuration.MaxDeviceConfiguration; import org.whispersystems.textsecuregcm.configuration.MessageCacheConfiguration; import org.whispersystems.textsecuregcm.configuration.PaymentsServiceConfiguration; @@ -242,6 +243,11 @@ public class WhisperServerConfiguration extends Configuration { @NotNull private BoostConfiguration boost; + @Valid + @JsonProperty + @NotNull + private GiftConfiguration gift; + @Valid @NotNull @JsonProperty @@ -417,6 +423,10 @@ public class WhisperServerConfiguration extends Configuration { return boost; } + public GiftConfiguration getGift() { + return gift; + } + public ReportMessageConfiguration getReportMessageConfiguration() { return reportMessage; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GiftConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GiftConfiguration.java new file mode 100644 index 000000000..9c7587aa8 --- /dev/null +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/GiftConfiguration.java @@ -0,0 +1,21 @@ +/* + * Copyright 2022 Signal Messenger, LLC + * SPDX-License-Identifier: AGPL-3.0-only + */ + +package org.whispersystems.textsecuregcm.configuration; + +import java.math.BigDecimal; +import java.time.Duration; +import java.util.Map; +import javax.validation.Valid; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +public record GiftConfiguration( + long level, + @NotNull Duration expiration, + @Valid @NotNull Map<@NotEmpty String, @DecimalMin("0.01") @NotNull BigDecimal> currencies, + @NotEmpty String badge) { +}