🐛 Trying to fix more subscription issue
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
Reference in New Issue
Block a user