fix(dto): add class-validator decorators for lead, advisor, and notification endpoints
Deploy Canina / deploy (push) Successful in 2m45s

This commit is contained in:
devops committed 2026-11-07 07:52:39 +00:00
1 parent fae4b570f9
commit 3a0e0f2acc
3 files changed
+188 -32

No files matched your search

@@ -11,10 +11,18 @@ import {
BadRequestException,
} from '@nestjs/common';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { EmailService, SmtpConfig } from './email.service';
import { EmailService } from './email.service';
import { NotificationsQueueService } from './notifications-queue.service';
import { SmsService } from '../common/services/sms.service';
import { PrismaService } from '../prisma/prisma.service';
import {
UpdateEmailConfigDto,
TestSmtpDto,
SendTestEmailDto,
SendTestSmsDto,
ManualSendDto,
CreateTemplateDto,
} from './notifications.dto';
@Controller('admin/notifications')
@UseGuards(JwtAuthGuard)
@@ -60,7 +68,7 @@ export class NotificationsController {
* Update SMTP Email config
*/
@Put('email-config')
async updateEmailConfig(@Body() dto: Partial<SmtpConfig>) {
async updateEmailConfig(@Body() dto: UpdateEmailConfigDto) {
// If password is masked, don't overwrite with dots
if (dto.password && dto.password.includes('•')) {
delete dto.password;
@@ -81,7 +89,7 @@ export class NotificationsController {
* Test SMTP connection live
*/
@Post('test-smtp')
async testSmtp(@Body() customConfig?: Partial<SmtpConfig>) {
async testSmtp(@Body() customConfig?: TestSmtpDto) {
if (customConfig?.password && customConfig.password.includes('•')) {
delete customConfig.password;
}
@@ -98,7 +106,7 @@ export class NotificationsController {
* Send test email
*/
@Post('send-test-email')
async sendTestEmail(@Body() body: { to: string; subject?: string; message?: string }) {
async sendTestEmail(@Body() body: SendTestEmailDto) {
if (!body.to) throw new BadRequestException('آدرس ایمیل مقصد الزامی است.');
const res = await this.emailService.sendMail({
@@ -132,7 +140,7 @@ export class NotificationsController {
* Send test SMS
*/
@Post('send-test-sms')
async sendTestSms(@Body() body: { to: string; message: string }) {
async sendTestSms(@Body() body: SendTestSmsDto) {
if (!body.to || !body.message) {
throw new BadRequestException('شماره موبایل و متن پیام الزامی است.');
}
@@ -150,17 +158,7 @@ export class NotificationsController {
* Manual targeted notification send
*/
@Post('manual-send')
async manualSend(
@Body()
body: {
channel: 'SMS' | 'EMAIL';
targetType: 'single' | 'all_users' | 'custom_list';
recipient?: string;
recipients?: string[];
subject?: string;
content: string;
},
) {
async manualSend(@Body() body: ManualSendDto) {
if (!body.channel || !body.content) {
throw new BadRequestException('کانال ارسال و متن پیام الزامی است.');
}
@@ -275,22 +273,7 @@ export class NotificationsController {
* Create or update notification template
*/
@Post('templates')
async upsertTemplate(
@Body()
dto: {
id?: string;
channel: 'SMS' | 'EMAIL';
event: string;
name: string;
subject?: string;
body: string;
patternCode?: string;
variables?: string[];
recipientType?: string;
customRecipient?: string;
isActive?: boolean;
},
) {
async upsertTemplate(@Body() dto: CreateTemplateDto) {
if (!dto.channel || !dto.event || !dto.name || !dto.body) {
throw new BadRequestException('اطلاعات ضروری قالب ناقص است.');
}