feat/Update_Controllers_to_Allow_for_Premium_Membership
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
namespace JobTrackerApi.Models;
|
||||
|
||||
public sealed record AccountEntitlements(bool AdvancedAi, bool PremiumThemes, bool Automation, bool Analytics, long StorageBytes, int MonthlyAiCalls, long MonthlyAiTokens);
|
||||
public sealed record AccountEntitlements(bool Ai, bool ProThemes, long StorageBytes, int MonthlyAiCalls, long MonthlyAiTokens);
|
||||
|
||||
public static class AccountPlans
|
||||
{
|
||||
public static bool IsPremiumSubscriptionStatus(string? status) =>
|
||||
status is "active" or "trialing";
|
||||
|
||||
public static AccountEntitlements ForRoles(IList<string> roles)
|
||||
public static AccountEntitlements ForRoles(IList<string>? roles)
|
||||
{
|
||||
var premium = roles.Contains("Premium", StringComparer.OrdinalIgnoreCase) || roles.Contains("Admin", StringComparer.OrdinalIgnoreCase);
|
||||
var premium = roles?.Contains("Premium", StringComparer.OrdinalIgnoreCase) == true
|
||||
|| roles?.Contains("Admin", StringComparer.OrdinalIgnoreCase) == true;
|
||||
return premium
|
||||
? new AccountEntitlements(true, true, true, true, 5_000_000_000, 250, 1_000_000)
|
||||
: new AccountEntitlements(false, false, false, false, 250_000_000, 25, 100_000);
|
||||
? new AccountEntitlements(true, true, 5_000_000_000, 250, 1_000_000)
|
||||
: new AccountEntitlements(false, false, 250_000_000, 0, 0);
|
||||
}
|
||||
|
||||
public static string Name(AccountEntitlements entitlements) => entitlements.Ai ? "pro" : "free";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ public sealed class ApplicationUser : IdentityUser
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
public string? PendingEmail { get; set; }
|
||||
public DateTimeOffset? PendingEmailRequestedAtUtc { get; set; }
|
||||
public string? ProfileCvText { get; set; }
|
||||
public string? ProfileCvStructureJson { get; set; }
|
||||
public int? CurrentCvUploadArtifactId { get; set; }
|
||||
@@ -17,6 +19,8 @@ public sealed class ApplicationUser : IdentityUser
|
||||
public string? GoogleEmail { get; set; }
|
||||
public DateTimeOffset? GoogleLinkedAt { get; set; }
|
||||
public string? MicrosoftSubject { get; set; }
|
||||
public string? MicrosoftTenantId { get; set; }
|
||||
public string? MicrosoftObjectId { get; set; }
|
||||
public string? MicrosoftEmail { get; set; }
|
||||
public DateTimeOffset? MicrosoftLinkedAt { get; set; }
|
||||
public string? TotpSecretEncrypted { get; set; }
|
||||
@@ -26,4 +30,6 @@ public sealed class ApplicationUser : IdentityUser
|
||||
public string? StripeSubscriptionId { get; set; }
|
||||
public string? StripeSubscriptionStatus { get; set; }
|
||||
public DateTime? StripeLastEventCreatedUtc { get; set; }
|
||||
public bool AiEnabled { get; set; } = true;
|
||||
public bool ExternalAiProcessingAllowed { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace JobTrackerApi.Models;
|
||||
|
||||
public sealed class UserNotification
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string OwnerUserId { get; set; } = string.Empty;
|
||||
public Guid? OperationId { get; set; }
|
||||
public UserOperation? Operation { get; set; }
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
public string? LinkPath { get; set; }
|
||||
public DateTime CreatedAtUtc { get; set; }
|
||||
public DateTime? ReadAtUtc { get; set; }
|
||||
public DateTime? DismissedAtUtc { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
namespace JobTrackerApi.Models;
|
||||
|
||||
public static class OperationStatuses
|
||||
{
|
||||
public const string Queued = "queued";
|
||||
public const string Running = "running";
|
||||
public const string WaitingForRetry = "waiting_for_retry";
|
||||
public const string WaitingForExternalFallback = "waiting_for_external_fallback";
|
||||
public const string Succeeded = "succeeded";
|
||||
public const string Failed = "failed";
|
||||
public const string Cancelled = "cancelled";
|
||||
|
||||
public static bool IsTerminal(string status) => status is Succeeded or Failed or Cancelled;
|
||||
}
|
||||
|
||||
public sealed class UserOperation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string OwnerUserId { get; set; } = string.Empty;
|
||||
public string TaskType { get; set; } = string.Empty;
|
||||
public string IdempotencyKey { get; set; } = string.Empty;
|
||||
public string Status { get; set; } = OperationStatuses.Queued;
|
||||
public int Priority { get; set; }
|
||||
public string EntitlementDecision { get; set; } = string.Empty;
|
||||
public string PrivacyPolicy { get; set; } = string.Empty;
|
||||
public string? SubjectType { get; set; }
|
||||
public string? SubjectId { get; set; }
|
||||
public string? Provider { get; set; }
|
||||
public string? Model { get; set; }
|
||||
public int AttemptCount { get; set; }
|
||||
public int MaxAttempts { get; set; } = 3;
|
||||
public DateTime CreatedAtUtc { get; set; }
|
||||
public DateTime AvailableAtUtc { get; set; }
|
||||
public DateTime? StartedAtUtc { get; set; }
|
||||
public DateTime? CompletedAtUtc { get; set; }
|
||||
public DateTime? DeadlineAtUtc { get; set; }
|
||||
public DateTime? CancellationRequestedAtUtc { get; set; }
|
||||
public string? LeaseToken { get; set; }
|
||||
public DateTime? LeaseExpiresAtUtc { get; set; }
|
||||
public DateTime? LastHeartbeatAtUtc { get; set; }
|
||||
public string? ProgressStage { get; set; }
|
||||
public int? ProgressPercent { get; set; }
|
||||
public string? FailureCategory { get; set; }
|
||||
public string? FailureMessage { get; set; }
|
||||
public string? ResultReference { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user