chore: fix bug in draft
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user