From e0dd53d639dba8bdf6a728df6ff8f038d0bb01e3 Mon Sep 17 00:00:00 2001 From: adonis Date: Sun, 20 Sep 2026 18:20:07 +0330 Subject: [PATCH] Reclaim tenant aliases from every other version, not only the same product. Co-authored-by: Cursor --- src/tenants/tenants.service.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/tenants/tenants.service.ts b/src/tenants/tenants.service.ts index 5429aef..404c53a 100644 --- a/src/tenants/tenants.service.ts +++ b/src/tenants/tenants.service.ts @@ -110,9 +110,8 @@ export class TenantsService { notes: dto.notes, }, }); - await this.reclaimAliasesFromSameProduct(tx, { + await this.reclaimAliasesFromOtherTenants(tx, { tenantId: created.id, - product: created.product, aliases, }); return created; @@ -193,9 +192,8 @@ export class TenantsService { try { const tenant = await this.prisma.$transaction(async (tx: any) => { if (nextAliases !== undefined) { - await this.reclaimAliasesFromSameProduct(tx, { + await this.reclaimAliasesFromOtherTenants(tx, { tenantId: id, - product: dto.product ?? before.product, aliases: nextAliases, }); } @@ -364,18 +362,18 @@ export class TenantsService { } /** - * دامنه/IP در aliases این نسخه، از domains[] نسخه‌های دیگر همان محصول برداشته می‌شود. - * خانگی و همکار جدا هستند؛ دامنهٔ اصلی (ستون domain) جابه‌جا نمی‌شود. + * دامنه/IP در aliases این نسخه، از domains[] همهٔ نسخه‌های دیگر برداشته می‌شود. + * دامنهٔ اصلی (ستون domain) جابه‌جا نمی‌شود. */ - private async reclaimAliasesFromSameProduct( + private async reclaimAliasesFromOtherTenants( tx: any, - opts: { tenantId: string; product: ProductType; aliases: string[] }, + opts: { tenantId: string; aliases: string[] }, ) { const keys = new Set(opts.aliases.map((item) => this.hostKey(item)).filter(Boolean)); if (!keys.size) return; const others = await tx.tenant.findMany({ - where: { product: opts.product, id: { not: opts.tenantId } }, + where: { id: { not: opts.tenantId } }, select: { id: true, nameFa: true, domain: true, domains: true }, });