chore: fix bug in draft

This commit is contained in:
mahyargdz
2025-08-04 15:32:07 +03:30
parent 199f1676bc
commit 6e2aba7db0
2 changed files with 7 additions and 8 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional, PartialType } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsArray,
@@ -296,6 +296,6 @@ export class SendEmailDto {
}
//########################################################
export class UpdateDraftDto extends SendEmailDto {
export class UpdateDraftDto extends PartialType(SendEmailDto) {
// Draft ID is passed in URL parameter, not in body
}
+5 -6
View File
@@ -483,9 +483,9 @@ export class EmailService {
await firstValueFrom(this.mailServerService.messages.deleteMessage(wildduckUserId, draftsMailboxId, messageId));
this.logger.log(`Existing draft message ${messageId} deleted before update`);
const draftData: SendEmailDto = {
const draftData: UpdateDraftDto = {
from: updateDraftDto.from || { address: existingDraft.from?.address || "" },
to: updateDraftDto.to || [],
to: updateDraftDto.to,
cc: updateDraftDto.cc,
bcc: updateDraftDto.bcc,
replyTo: updateDraftDto.replyTo,
@@ -505,8 +505,8 @@ export class EmailService {
if (user && user.business && (updateDraftDto.text || updateDraftDto.html)) {
const processedTemplate = await this.templateProcessorService.processEmailContent(user.business.id, user.id, {
text: updateDraftDto.text,
html: updateDraftDto.html,
text: updateDraftDto.text!,
html: updateDraftDto.html!,
subject: updateDraftDto.subject,
});
@@ -525,12 +525,11 @@ export class EmailService {
draftData.headers = [...(draftData.headers || []), ...headers];
}
const response = await firstValueFrom(this.mailServerService.submission.submitMessage(wildduckUserId, draftData));
const response = await firstValueFrom(this.mailServerService.submission.submitMessage(wildduckUserId, draftData as SendEmailDto));
return {
message: EmailMessage.DRAFT_UPDATED_SUCCESSFULLY,
messageId: response.message.id,
subject: "Draft",
isDraft: true,
};
}