✨ Post detail page
This commit is contained in:
@@ -183,7 +183,7 @@ async function fetchUser() {
|
||||
|
||||
console.log('[Fetch] Using the API to load user data.')
|
||||
try {
|
||||
const resp = await fetch(`/api/accounts/${route.params.name}`)
|
||||
const resp = await fetch(`/api/accounts/${route.params.slug}`)
|
||||
user.value = await resp.json()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
@@ -43,13 +43,11 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
||||
|
||||
var subs = await db.WalletSubscriptions
|
||||
var subscription = await db.WalletSubscriptions
|
||||
.Where(s => s.AccountId == currentUser.Id && s.IsActive)
|
||||
.Where(s => EF.Functions.ILike(s.Identifier, prefix + "%"))
|
||||
.OrderByDescending(s => s.BegunAt)
|
||||
.ToListAsync();
|
||||
if (subs.Count == 0) return NotFound();
|
||||
var subscription = subs.FirstOrDefault(s => s.IsAvailable);
|
||||
.FirstOrDefaultAsync();
|
||||
if (subscription is null) return NotFound();
|
||||
|
||||
return Ok(subscription);
|
||||
|
@@ -400,9 +400,9 @@ public class SubscriptionService(
|
||||
.OrderByDescending(s => s.BegunAt)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
// Cache the result if found (with 30 minutes expiry)
|
||||
// Cache the result if found (with 5 minutes expiry)
|
||||
if (subscription != null)
|
||||
await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(30));
|
||||
await cache.SetAsync(cacheKey, subscription, TimeSpan.FromMinutes(5));
|
||||
|
||||
return subscription;
|
||||
}
|
||||
|
Reference in New Issue
Block a user