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 { Type } from "class-transformer";
import { import {
IsArray, 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 // 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)); await firstValueFrom(this.mailServerService.messages.deleteMessage(wildduckUserId, draftsMailboxId, messageId));
this.logger.log(`Existing draft message ${messageId} deleted before update`); this.logger.log(`Existing draft message ${messageId} deleted before update`);
const draftData: SendEmailDto = { const draftData: UpdateDraftDto = {
from: updateDraftDto.from || { address: existingDraft.from?.address || "" }, from: updateDraftDto.from || { address: existingDraft.from?.address || "" },
to: updateDraftDto.to || [], to: updateDraftDto.to,
cc: updateDraftDto.cc, cc: updateDraftDto.cc,
bcc: updateDraftDto.bcc, bcc: updateDraftDto.bcc,
replyTo: updateDraftDto.replyTo, replyTo: updateDraftDto.replyTo,
@@ -505,8 +505,8 @@ export class EmailService {
if (user && user.business && (updateDraftDto.text || updateDraftDto.html)) { if (user && user.business && (updateDraftDto.text || updateDraftDto.html)) {
const processedTemplate = await this.templateProcessorService.processEmailContent(user.business.id, user.id, { const processedTemplate = await this.templateProcessorService.processEmailContent(user.business.id, user.id, {
text: updateDraftDto.text, text: updateDraftDto.text!,
html: updateDraftDto.html, html: updateDraftDto.html!,
subject: updateDraftDto.subject, subject: updateDraftDto.subject,
}); });
@@ -525,12 +525,11 @@ export class EmailService {
draftData.headers = [...(draftData.headers || []), ...headers]; 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 { return {
message: EmailMessage.DRAFT_UPDATED_SUCCESSFULLY, message: EmailMessage.DRAFT_UPDATED_SUCCESSFULLY,
messageId: response.message.id, messageId: response.message.id,
subject: "Draft",
isDraft: true, isDraft: true,
}; };
} }