chore: new feature

This commit is contained in:
mahyargdz
2025-07-21 10:22:58 +03:30
parent a5d28b7f26
commit abfdd1b9e7
5 changed files with 35 additions and 2 deletions
+2
View File
@@ -224,6 +224,8 @@ export const enum EmailMessage {
SUBJECT_REQUIRED = "موضوع ایمیل مورد نیاز است",
ALL_MESSAGES_DELETED_SUCCESSFULLY = "همه پیام ها با موفقیت حذف شدند",
MAILBOX_ID_MUST_BE_MONGO_ID = "شناسه میل باکس ایمیل باید یک آی دی معتبر باشد",
MESSAGE_MARKED_AS_UNSEEN_SUCCESSFULLY = "پیام با موفقیت به عنوان خوانده نشده علامت گذاری شد",
MESSAGE_MARK_AS_UNSEEN_FAILED = "علامت گذاری پیام به عنوان خوانده نشده با خطا مواجه شد",
}
export const enum WebSocketMessage {
+8
View File
@@ -67,6 +67,14 @@ export class EmailController {
return this.emailService.markMessageAsSeen(userId, Number(params.messageId), query.mailbox);
}
@Patch("messages/:messageId/unseen")
@ApiOperation({ summary: "Mark a message as unseen" })
@ApiResponse({ status: 200, description: "Message marked as unseen successfully" })
@ApiResponse({ status: 404, description: "Message not found" })
markMessageAsUnseen(@UserDec("wildduckUserId") userId: string, @Param() params: MessageParamDto, @Query() query: MailboxIdQueryDto) {
return this.emailService.markMessageAsUnseen(userId, Number(params.messageId), query.mailbox);
}
@Get("messages/inbox")
@ApiOperation({ summary: "List messages in a inbox" })
@ApiResponse({ status: 200, description: "List of messages" })
@@ -33,6 +33,8 @@ export class EmailSpamService {
}
}
} catch (_error) {
// Expected: 404 errors occur when the message doesn't exist in this mailbox
// Continue searching other mailboxes
continue;
}
}
@@ -101,7 +103,7 @@ export class EmailSpamService {
await firstValueFrom(
this.mailServerService.domainAccess.addAllowedDomain(domainTag, {
domain: senderInfo.senderDomain,
description: `Auto-allowed due to not-spam report from message ${messageId}`,
// Removed description field as WildDuck API doesn't accept it for allowlist operations
}),
);
@@ -269,6 +269,27 @@ export class EmailService {
}
}
//==============================================
async markMessageAsUnseen(wildduckUserId: string, messageId: number, mailboxId: string) {
try {
this.logger.log(`Marking message ${messageId} as unseen in ${mailboxId} mailbox for user: ${wildduckUserId}`);
const { updated } = await firstValueFrom(this.mailServerService.messages.updateMessage(wildduckUserId, mailboxId, messageId, { seen: false }));
this.logger.log(`Message ${messageId} marked as unseen successfully in ${mailboxId}`);
return {
success: true,
message: EmailMessage.MESSAGE_MARKED_AS_UNSEEN_SUCCESSFULLY,
updated,
};
} catch (error) {
this.logger.error(
`Failed to mark message ${messageId} as unseen for user ${wildduckUserId}: ${error instanceof Error ? error.message : "Unknown error"}`,
);
throw error;
}
}
//==============================================
async getSentMessages(wildduckUserId: string, query: MessageListQueryDto) {
try {
@@ -11,7 +11,7 @@ export class CreateDomainAccessDto {
domain: string;
@ApiPropertyOptional({
description: "Optional description for this domain entry",
description: "Optional description for this domain entry. Note: May not be supported for all operations (e.g., allowlist operations)",
example: "Trusted business partner domain",
})
@IsOptional()