Files
api/prisma/khanegi-variant-locks.ts
MahdiandCursor dd4850d9fa fix: lock new.gholaktala.ir as Khanegi newTheme (userTheme)
Correct prior modular/Hamkar misclassification. Protect locked newTheme domains from bulk-modular brand overrides.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 17:53:04 +03:30

54 lines
1.6 KiB
TypeScript

/**
* Khanegi tenants that MUST stay on userTheme (uiVariant=newTheme).
* Never force these to modular in bulk brand scripts.
*
* Frontend: KhanegiModular/userTheme
* API: /api/get_settings (NOT Hamkar /site/settings, NOT userModular-only assumptions)
*/
export const FORCE_KHANEGI_NEW_THEME_DOMAINS = [
'new.gholaktala.ir',
'app.aygingold.ir',
] as const
export function normalizeTenantHost(value?: string | null) {
if (!value) return ''
return String(value)
.trim()
.toLowerCase()
.replace(/^https?:\/\//, '')
.split('/')[0]
.split(':')[0]
}
export function collectTenantHosts(domain: string, domains: unknown, slug = '') {
const hosts = new Set<string>()
const primary = normalizeTenantHost(domain)
if (primary) hosts.add(primary)
const extra = Array.isArray(domains) ? domains : []
for (const d of extra) {
const n = normalizeTenantHost(String(d))
if (n) hosts.add(n)
}
const s = String(slug || '').toLowerCase()
if (s) hosts.add(s)
return hosts
}
export function isForcedKhanegiNewTheme(domain: string, domains: unknown, slug = '') {
const hosts = collectTenantHosts(domain, domains, slug)
const slugLower = String(slug || '').toLowerCase()
if (slugLower.includes('aygin') || slugLower.includes('gholak_new')) return true
for (const h of hosts) {
if (h === 'new.gholaktala.ir') return true
if (h.includes('aygingold') || h === 'app.aygingold.ir') return true
}
for (const locked of FORCE_KHANEGI_NEW_THEME_DOMAINS) {
const needle = normalizeTenantHost(locked)
if (hosts.has(needle)) return true
}
return false
}