chore: changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, Query } from "@nestjs/common";
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
||||
import { ApiOperation, ApiResponse } from "@nestjs/swagger";
|
||||
|
||||
import { QueueIdParamDto, UserMailboxMessageParamDto } from "./DTO/email-params.dto";
|
||||
@@ -9,8 +9,8 @@ import { EmailService } from "./services/email.service";
|
||||
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
||||
import { UserDec } from "../../common/decorators/user.decorator";
|
||||
|
||||
@Controller("email")
|
||||
@AuthGuards()
|
||||
@Controller("email")
|
||||
export class EmailController {
|
||||
constructor(private readonly emailService: EmailService) {}
|
||||
|
||||
@@ -19,8 +19,8 @@ export class EmailController {
|
||||
@ApiResponse({ status: 201, description: "Email sent successfully" })
|
||||
@ApiResponse({ status: 400, description: "Invalid email data" })
|
||||
@ApiResponse({ status: 403, description: "Not authorized to send email" })
|
||||
sendEmail(@UserDec("id") userId: string, @Body() sendEmailDto: SendEmailDto) {
|
||||
return this.emailService.sendEmail(userId, sendEmailDto);
|
||||
sendEmail(@UserDec("wildduckUserId") userEmailId: string, @Body() sendEmailDto: SendEmailDto) {
|
||||
return this.emailService.sendEmail(userEmailId, sendEmailDto);
|
||||
}
|
||||
|
||||
@Get("status/:queueId")
|
||||
@@ -35,7 +35,7 @@ export class EmailController {
|
||||
@ApiOperation({ summary: "List messages in a inbox" })
|
||||
@ApiResponse({ status: 200, description: "List of messages" })
|
||||
@ApiResponse({ status: 404, description: "Mailbox not found" })
|
||||
listMessages(@UserDec("id") userId: string, @UserDec("inboxId") inboxId: string, @Query() query: MessageListQueryDto) {
|
||||
listMessages(@UserDec("wildduckUserId") userId: string, @UserDec("inboxId") inboxId: string, @Query() query: MessageListQueryDto) {
|
||||
return this.emailService.listMessages(userId, inboxId, query);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class EmailController {
|
||||
@ApiOperation({ summary: "Get a specific message" })
|
||||
@ApiResponse({ status: 200, description: "Message details" })
|
||||
@ApiResponse({ status: 404, description: "Message not found" })
|
||||
getMessage(@UserDec("id") userId: string, @UserDec("inboxId") inboxId: string, @Param() params: UserMailboxMessageParamDto) {
|
||||
getMessage(@UserDec("wildduckUserId") userId: string, @UserDec("inboxId") inboxId: string, @Param() params: UserMailboxMessageParamDto) {
|
||||
return this.emailService.getMessage(userId, inboxId, params.messageId);
|
||||
}
|
||||
|
||||
@@ -51,14 +51,38 @@ export class EmailController {
|
||||
@ApiOperation({ summary: "Delete a message" })
|
||||
@ApiResponse({ status: 200, description: "Message deleted successfully" })
|
||||
@ApiResponse({ status: 404, description: "Message not found" })
|
||||
deleteMessage(@UserDec("id") userId: string, @UserDec("inboxId") inboxId: string, @Param() params: UserMailboxMessageParamDto) {
|
||||
deleteMessage(@UserDec("wildduckUserId") userId: string, @UserDec("inboxId") inboxId: string, @Param() params: UserMailboxMessageParamDto) {
|
||||
return this.emailService.deleteMessage(userId, inboxId, params.messageId);
|
||||
}
|
||||
|
||||
@Get("search")
|
||||
@ApiOperation({ summary: "Search messages across all mailboxes" })
|
||||
@ApiResponse({ status: 200, description: "Search results" })
|
||||
searchMessages(@UserDec("id") userId: string, @Query() query: SearchMessagesQueryDto) {
|
||||
searchMessages(@UserDec("wildduckUserId") userId: string, @Query() query: SearchMessagesQueryDto) {
|
||||
return this.emailService.searchMessages(userId, query);
|
||||
}
|
||||
|
||||
@Patch("messages/:messageId/seen")
|
||||
@ApiOperation({ summary: "Mark a message as seen" })
|
||||
@ApiResponse({ status: 200, description: "Message marked as seen successfully" })
|
||||
@ApiResponse({ status: 404, description: "Message not found" })
|
||||
markMessageAsSeen(@UserDec("wildduckUserId") userId: string, @UserDec("inboxId") inboxId: string, @Param() params: UserMailboxMessageParamDto) {
|
||||
return this.emailService.markMessageAsSeen(userId, inboxId, Number(params.messageId));
|
||||
}
|
||||
|
||||
@Get("messages/sent")
|
||||
@ApiOperation({ summary: "List messages in sent mailbox" })
|
||||
@ApiResponse({ status: 200, description: "List of sent messages" })
|
||||
@ApiResponse({ status: 404, description: "Sent mailbox not found" })
|
||||
getSentMessages(@UserDec("wildduckUserId") userId: string, @UserDec("sentId") sentId: string, @Query() query: MessageListQueryDto) {
|
||||
return this.emailService.getSentMessages(userId, sentId, query);
|
||||
}
|
||||
|
||||
@Get("messages/trash")
|
||||
@ApiOperation({ summary: "List messages in trash mailbox" })
|
||||
@ApiResponse({ status: 200, description: "List of trash messages" })
|
||||
@ApiResponse({ status: 404, description: "Trash mailbox not found" })
|
||||
getTrashMessages(@UserDec("wildduckUserId") userId: string, @UserDec("trashId") trashId: string, @Query() query: MessageListQueryDto) {
|
||||
return this.emailService.getTrashMessages(userId, trashId, query);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user