fix(delivery): replace hardcoded product URL/name maps with dynamic product cache lookup

This commit is contained in:
saravanakumardb1 2026-03-01 17:44:54 -08:00
parent 2f199cb67a
commit 92a6929238

View File

@ -1,4 +1,5 @@
import { bus } from '../../lib/event-bus.js'; import { bus } from '../../lib/event-bus.js';
import { getProduct } from '../products/cache.js';
import { dispatchEmail } from './dispatcher.js'; import { dispatchEmail } from './dispatcher.js';
// ── Event Bus Subscribers ──────────────────────────────────── // ── Event Bus Subscribers ────────────────────────────────────
@ -140,21 +141,15 @@ export function registerDeliverySubscribers(
// ── Helpers ────────────────────────────────────────────────── // ── Helpers ──────────────────────────────────────────────────
function resolveDashboardUrl(productId: string): string { function resolveDashboardUrl(productId: string): string {
const urls: Record<string, string> = { const envKey = `${productId.toUpperCase()}_DASHBOARD_URL`;
lysnrai: process.env.LYSNRAI_DASHBOARD_URL || 'https://app.lysnrai.com', const envUrl = process.env[envKey];
chronomind: process.env.CHRONOMIND_DASHBOARD_URL || 'https://chronomind.app', if (envUrl) return envUrl;
nomgap: process.env.NOMGAP_DASHBOARD_URL || 'https://nomgap.app', const product = getProduct(productId);
mindlyst: process.env.MINDLYST_DASHBOARD_URL || 'https://mindlyst.app', if (product?.websiteUrl) return product.websiteUrl;
}; return `https://${productId}.bytelyst.com`;
return urls[productId] || `https://${productId}.bytelyst.com`;
} }
function resolveProductName(productId: string): string { function resolveProductName(productId: string): string {
const names: Record<string, string> = { const product = getProduct(productId);
lysnrai: 'LysnrAI', return product?.displayName || productId;
chronomind: 'ChronoMind',
nomgap: 'NomGap',
mindlyst: 'MindLyst',
};
return names[productId] || productId;
} }