diff --git a/VoidCat/Model/Paywall/Paywall.cs b/VoidCat/Model/Paywall/Paywall.cs index 8925b27..b30a5e2 100644 --- a/VoidCat/Model/Paywall/Paywall.cs +++ b/VoidCat/Model/Paywall/Paywall.cs @@ -1,6 +1,4 @@ -using System.Text.Json.Serialization; - -namespace VoidCat.Model.Paywall; +namespace VoidCat.Model.Paywall; public enum PaywallServices { @@ -9,4 +7,8 @@ public enum PaywallServices } public abstract record PaywallConfig(PaywallServices Service, PaywallMoney Cost); -public record StrikePaywallConfig(string Handle, PaywallMoney Cost) : PaywallConfig(PaywallServices.Strike, Cost); + +public record StrikePaywallConfig(PaywallServices Service, PaywallMoney Cost) : PaywallConfig(Service, Cost) +{ + public string Handle { get; init; } +} \ No newline at end of file diff --git a/VoidCat/Program.cs b/VoidCat/Program.cs index 64976f9..41a96eb 100644 --- a/VoidCat/Program.cs +++ b/VoidCat/Program.cs @@ -35,6 +35,8 @@ services.AddRouting(); services.AddControllers().AddNewtonsoftJson((opt) => { opt.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; + opt.SerializerSettings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; + opt.SerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore; }); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => diff --git a/VoidCat/Services/Redis/RedisPaywallStore.cs b/VoidCat/Services/Redis/RedisPaywallStore.cs index 43b8196..512e6e1 100644 --- a/VoidCat/Services/Redis/RedisPaywallStore.cs +++ b/VoidCat/Services/Redis/RedisPaywallStore.cs @@ -17,7 +17,7 @@ public class RedisPaywallStore : IPaywallStore public async ValueTask GetConfig(Guid id) { var json = await _database.StringGetAsync(ConfigKey(id)); - var cfg = json.HasValue ? JsonConvert.DeserializeObject(json) : default; + var cfg = json.HasValue ? JsonConvert.DeserializeObject(json) : default; return cfg?.Service switch { PaywallServices.Strike => JsonConvert.DeserializeObject(json), @@ -44,4 +44,9 @@ public class RedisPaywallStore : IPaywallStore private RedisKey ConfigKey(Guid id) => $"paywall:config:{id}"; private RedisKey OrderKey(Guid id) => $"paywall:order:{id}"; + + internal class PaywallBlank + { + public PaywallServices Service { get; init; } + } } \ No newline at end of file