fix: sidebar accordion + koja slug + support ticket LINQ crash
CI/CD / CI · API (dotnet build + test) (push) Successful in 5m50s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 32s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m3s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 48s
CI/CD / Deploy · all services (push) Has been cancelled

Sidebar:
- All groups start collapsed on first load (v4 storage key resets old state)
- Opening one group closes all others (accordion)
- Navigating to a section opens only that section's group

Koja slug:
- SlugHelper: Persian->Latin transliteration, slug validation
- Registration accepts optional custom slug; auto-derives from cafe name
- Slug can be updated from dashboard Settings -> Profile
- Settings PATCH validates uniqueness (SLUG_TAKEN) and format (INVALID_SLUG)
- koja.meezi.ir/{slug} now redirects to /fa/cafe/{slug} (short URL support)

Bug fix:
- SupportTicketService: cafeId/status filters applied before Select() projection
  to fix EF "could not be translated" crash on the support tickets page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-05-31 22:28:25 +03:30
parent 38e3f6a5a2
commit cd1af30bbc
17 changed files with 401 additions and 58 deletions
+45 -8
View File
@@ -303,8 +303,15 @@ public class AuthService : IAuthService
var otp = Random.Shared.Next(100000, 999999).ToString();
await redis.StringSetAsync($"otp:{phone}", otp, TimeSpan.FromSeconds(OtpTtlSeconds));
// Store the cafe name alongside the OTP so verify-register can create the cafe
await redis.StringSetAsync($"reg_meta:{phone}", cafeName, TimeSpan.FromSeconds(OtpTtlSeconds));
// Determine the requested slug: use provided slug, or auto-derive from café name.
// Format stored: "cafeName||slug" (double-pipe delimiter). Slug may be empty.
var requestedSlug = string.IsNullOrWhiteSpace(request.Slug)
? Meezi.Core.Utilities.SlugHelper.Slugify(cafeName)
: request.Slug.Trim().ToLowerInvariant();
var regMeta = $"{cafeName}||{requestedSlug}";
await redis.StringSetAsync($"reg_meta:{phone}", regMeta, TimeSpan.FromSeconds(OtpTtlSeconds));
try
{
@@ -342,10 +349,25 @@ public class AuthService : IAuthService
if (storedOtp.IsNullOrEmpty || storedOtp.ToString() != code)
return (false, null, "INVALID_OTP", "Invalid or expired verification code.");
var cafeName = (await redis.StringGetAsync($"reg_meta:{phone}")).ToString();
if (string.IsNullOrWhiteSpace(cafeName))
var regMetaRaw = (await redis.StringGetAsync($"reg_meta:{phone}")).ToString();
if (string.IsNullOrWhiteSpace(regMetaRaw))
return (false, null, "REGISTRATION_EXPIRED", "Registration session expired. Please start again.");
// Parse "cafeName||slug" format (double-pipe delimiter)
string cafeName;
string? requestedSlug;
var sepIdx = regMetaRaw.IndexOf("||", StringComparison.Ordinal);
if (sepIdx >= 0)
{
cafeName = regMetaRaw[..sepIdx];
requestedSlug = regMetaRaw[(sepIdx + 2)..];
}
else
{
cafeName = regMetaRaw;
requestedSlug = null;
}
// Double-check no owner was created in the meantime (race condition guard)
var alreadyOwner = await _db.Employees
.AnyAsync(e => e.Phone == phone && e.Role == EmployeeRole.Owner && e.DeletedAt == null, cancellationToken);
@@ -356,8 +378,8 @@ public class AuthService : IAuthService
return (false, null, "ALREADY_REGISTERED", "An account already exists for this phone number. Please sign in.");
}
// Generate a unique slug
var slug = await GenerateUniqueSlugAsync(cancellationToken);
// Generate a unique slug (try requested slug first, fall back to random)
var slug = await GenerateUniqueSlugAsync(requestedSlug, cancellationToken);
var cafe = new Cafe
{
@@ -402,12 +424,27 @@ public class AuthService : IAuthService
return (true, tokens, null, null);
}
private async Task<string> GenerateUniqueSlugAsync(CancellationToken ct)
private async Task<string> GenerateUniqueSlugAsync(string? preferred, CancellationToken ct)
{
// Try the preferred/derived slug first
if (Meezi.Core.Utilities.SlugHelper.IsValidSlug(preferred))
{
if (!await _db.Cafes.AnyAsync(c => c.Slug == preferred, ct))
return preferred!;
// Preferred slug is taken — append a short random suffix
for (var i = 0; i < 10; i++)
{
var candidate = $"{preferred}-{Guid.NewGuid().ToString("N")[..4]}";
if (!await _db.Cafes.AnyAsync(c => c.Slug == candidate, ct))
return candidate;
}
}
// Full random fallback
string slug;
do
{
// e.g. "cafe-a3f9b2c"
slug = "cafe-" + Guid.NewGuid().ToString("N")[..7];
} while (await _db.Cafes.AnyAsync(c => c.Slug == slug, ct));
return slug;