feat: add resource quotas, PayPal subscriptions and paid disk allowances

Calculate and enforce configurable resource consumption, expose balances in PostIt and document the rule in CGU. Add confirmed monthly PayPal credits and disk quotas of twice the free default for Discovery and five times for Premium, with payment reconciliation, migrations and regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-11-08 05:02:23 +00:00
commit 650e5f5e30
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
69 changed files with 19111 additions and 203 deletions

View file

@ -0,0 +1,21 @@
#nullable enable
namespace Yavsc.Settings;
public sealed class ResourceUsageOptions
{
public const string SectionName = "ResourceUsage";
public decimal ApiCallWeight { get; set; } = 0.2m;
public decimal CpuSecondWeight { get; set; } = 0.1m;
public decimal BandwidthMbWeight { get; set; } = 0.05m;
public decimal StorageMbWeight { get; set; } = 0.5m;
public decimal DefaultLimit { get; set; } = 1000m;
public Dictionary<string, decimal> UserLimits { get; set; } = new();
public decimal GetLimit(string userId)
=> UserLimits.TryGetValue(userId, out var limit) ? limit : DefaultLimit;
public decimal Calculate(decimal apiCalls, decimal cpuSeconds, decimal bandwidthMb, decimal storageMb)
=> apiCalls * ApiCallWeight + cpuSeconds * CpuSecondWeight
+ bandwidthMb * BandwidthMbWeight + storageMb * StorageMbWeight;
}