diff --git a/openapi.json b/openapi.json index dc32a6c..43c1eac 100644 --- a/openapi.json +++ b/openapi.json @@ -1,5 +1,5 @@ { - "hash": "50b02791c7a6d303f38dd96ffece6974ae0eb8160c754e35f57027533f749d24", + "hash": "ce722f966bbb3c4eabd198291cd5cdc8eebf36391ba8eb0458d107822cfc8037", "openapi": "3.0.0", "paths": { "/hello": { @@ -834,7 +834,7 @@ "description": "No content." } }, - "summary": "Send plain text email", + "summary": "Send email", "tags": [ "email" ] @@ -6356,6 +6356,9 @@ }, "content": { "type": "string" + }, + "useHtml": { + "type": "boolean" } }, "required": [ diff --git a/src/email/dto/send-email.dto.ts b/src/email/dto/send-email.dto.ts index 46fbec1..a6c55fa 100644 --- a/src/email/dto/send-email.dto.ts +++ b/src/email/dto/send-email.dto.ts @@ -1,4 +1,4 @@ -import { IsEmail, IsNotEmpty, IsString } from 'class-validator'; +import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator'; export class SendEmailDto { @IsNotEmpty() @@ -16,4 +16,8 @@ export class SendEmailDto { @IsNotEmpty() @IsString() content: string; + + @IsOptional() + @IsBoolean() + useHtml?: boolean; } diff --git a/src/email/email.controller.ts b/src/email/email.controller.ts index 4cdbf3b..ac61de5 100644 --- a/src/email/email.controller.ts +++ b/src/email/email.controller.ts @@ -28,7 +28,7 @@ export class EmailController { ) {} /** - * Send plain text email + * Send email */ @ApiOperation({ operationId: 'sendEmail' }) @ApiNoContentResponse({ description: 'No content.' }) diff --git a/src/email/email.service.ts b/src/email/email.service.ts index e44ef1b..0ddc7d8 100644 --- a/src/email/email.service.ts +++ b/src/email/email.service.ts @@ -38,14 +38,7 @@ export class EmailService { sendEmail(dto: SendEmailDto) { return this.mailer.send({ ...dto, - useHtml: false, - }); - } - - sendHtmlEmail(dto: SendEmailDto) { - return this.mailer.send({ - ...dto, - useHtml: true, + useHtml: !!dto.useHtml, }); } }