Make Arvan DNS updates opt-in and persist English user names.

Domain add/edit only upserts Arvan records when updateDns is true, and super-admin user PATCH now accepts firstNameEn and lastNameEn.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-20 11:50:57 +03:30
co-authored by Cursor
parent f61bba317e
commit 8609d8d4fd
8 changed files with 89 additions and 7 deletions
+2 -1
View File
@@ -1,12 +1,13 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { AuthModule } from '../auth/auth.module';
import { ArvanDnsModule } from '../arvan-dns/arvan-dns.module';
import { WebsiteDeployModule } from '../website-deploy/website-deploy.module';
import { DomainAdminController } from './domain-admin.controller';
import { DomainAdminService } from './domain-admin.service';
@Module({
imports: [AuthModule, ConfigModule, WebsiteDeployModule],
imports: [AuthModule, ConfigModule, WebsiteDeployModule, ArvanDnsModule],
controllers: [DomainAdminController],
providers: [DomainAdminService],
})
+32 -1
View File
@@ -2,12 +2,14 @@ import {
BadRequestException,
ConflictException,
ForbiddenException,
HttpException,
Injectable,
NotFoundException,
ServiceUnavailableException,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Prisma } from '@prisma/client';
import { ArvanDnsService } from '../arvan-dns/arvan-dns.service';
import { AuthUser } from '../auth/auth.types';
import { PermissionsService } from '../auth/permissions.service';
import { probeTlsHost } from '../common/tls-probe';
@@ -39,6 +41,7 @@ export class DomainAdminService {
private readonly permissions: PermissionsService,
private readonly config: ConfigService,
private readonly websiteDeployAgent: WebsiteDeployAgentService,
private readonly arvanDns: ArvanDnsService,
) {}
private async assertSuperAdmin(actor: AuthUser) {
@@ -478,13 +481,41 @@ export class DomainAdminService {
}
}
return this.prisma.domain.update({
const updated = await this.prisma.domain.update({
where: { id: domainId },
data: {
host: dto.host?.trim(),
expiresAt: dto.expiresAt !== undefined ? new Date(dto.expiresAt) : undefined,
},
});
const host = updated.host;
const dnsError = dto.updateDns ? await this.applyArvanDns(host) : null;
return {
...updated,
dnsError,
};
}
private async applyArvanDns(host: string): Promise<string | null> {
try {
await this.arvanDns.ensureTenantRecords(host);
return null;
} catch (err) {
if (err instanceof HttpException) {
const res = err.getResponse();
if (typeof res === 'string') return res;
if (res && typeof res === 'object' && 'message' in res) {
const message = (res as { message: unknown }).message;
return Array.isArray(message) ? message.map(String).join(', ') : String(message);
}
}
if (err && typeof err === 'object' && 'message' in err && typeof err.message === 'string') {
return err.message;
}
return 'Arvan DNS update failed';
}
}
async disable(domainIdRaw: string, dto: DisableDomainDto, actor: AuthUser) {
@@ -1,4 +1,4 @@
import { IsDateString, IsOptional, IsString, MinLength } from 'class-validator';
import { IsBoolean, IsDateString, IsOptional, IsString, MinLength } from 'class-validator';
export class UpdateDomainAdminDto {
@IsOptional()
@@ -9,4 +9,9 @@ export class UpdateDomainAdminDto {
@IsOptional()
@IsDateString()
expiresAt?: string;
/** When true, upsert Meshkee tenant records in Arvan DNS. */
@IsOptional()
@IsBoolean()
updateDns?: boolean;
}