feat: SMTP config en DB, historial mensajes, JWT 90d, email OTP con Prisma
- schema.prisma: modelo message_logs (channel, recipient, body, status, error) - email-otp.service.ts: lee config SMTP desde DB (settings.smtp_config), registra log en message_logs - sms.service.ts: registra log en message_logs tras cada envío (éxito y error) - auth.module.ts: agrega PrismaModule, JWT expira en 90d - settings.controller.ts: GET/PATCH /settings/smtp + GET /settings/message-logs - settings.service.ts: método getMessageLogs con paginación y filtro por canal - settings.module.ts: importa AuthModule + EmailOtpService Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a9b5e413e3
commit
522adc3b74
@@ -45,6 +45,9 @@ export class SmsService {
|
||||
});
|
||||
} catch (networkErr) {
|
||||
this.logger.error(`Error de red al conectar con proveedor SMS: ${networkErr}`);
|
||||
await this.prisma.message_logs.create({
|
||||
data: { channel: 'sms', recipient: numero, body: mensaje, status: 'error', error: String(networkErr) },
|
||||
}).catch(() => {});
|
||||
throw new BadRequestException('No se pudo conectar con el proveedor de SMS. Intenta de nuevo.');
|
||||
}
|
||||
|
||||
@@ -56,6 +59,9 @@ export class SmsService {
|
||||
|
||||
const result = await res.json().catch(() => ({ ok: true }));
|
||||
this.logger.log(`SMS enviado a ${normalizedNumero}`);
|
||||
await this.prisma.message_logs.create({
|
||||
data: { channel: 'sms', recipient: normalizedNumero, body: mensaje, status: 'sent' },
|
||||
}).catch(() => {});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user