🐛 Trying to fix more subscription issue

This commit is contained in:
2025-08-09 22:52:02 +08:00
parent 765be4f214
commit 1c52b4d661
2 changed files with 5 additions and 3 deletions

View File

@@ -9,7 +9,8 @@ namespace DysonNetwork.Pass.Wallet;
[ApiController] [ApiController]
[Route("/api/subscriptions")] [Route("/api/subscriptions")]
public class SubscriptionController(SubscriptionService subscriptions, AfdianPaymentHandler afdian, AppDatabase db) : ControllerBase public class SubscriptionController(SubscriptionService subscriptions, AfdianPaymentHandler afdian, AppDatabase db)
: ControllerBase
{ {
[HttpGet] [HttpGet]
[Authorize] [Authorize]
@@ -48,7 +49,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay
.Where(s => EF.Functions.ILike(s.Identifier, prefix + "%")) .Where(s => EF.Functions.ILike(s.Identifier, prefix + "%"))
.OrderByDescending(s => s.BegunAt) .OrderByDescending(s => s.BegunAt)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (subscription is null) return NotFound(); if (subscription is null || !subscription.IsAvailable) return NotFound();
return Ok(subscription); return Ok(subscription);
} }

View File

@@ -399,6 +399,7 @@ public class SubscriptionService(
.Where(s => s.AccountId == accountId && identifiers.Contains(s.Identifier)) .Where(s => s.AccountId == accountId && identifiers.Contains(s.Identifier))
.OrderByDescending(s => s.BegunAt) .OrderByDescending(s => s.BegunAt)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (subscription is { IsAvailable: false }) subscription = null;
// Cache the result if found (with 5 minutes expiry) // Cache the result if found (with 5 minutes expiry)
if (subscription != null) if (subscription != null)