chore: add new route to get favorinte and archive mailboxx messsage
This commit is contained in:
@@ -193,6 +193,63 @@ export class EmailService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
//==============================================
|
||||
|
||||
async getJunkMessages(userId: string, query: MessageListQueryDto) {
|
||||
try {
|
||||
const junkMailboxId = await this.mailboxResolverService.getJunkMailboxId(userId);
|
||||
const { results: junkMails, total: count } = await firstValueFrom(this.mailServerService.messages.listMessages(userId, junkMailboxId, query));
|
||||
|
||||
return {
|
||||
junkMails,
|
||||
count,
|
||||
paginate: true,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to get junk messages for user ${userId}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
//==============================================
|
||||
|
||||
async getArchivedMessages(userId: string, query: MessageListQueryDto) {
|
||||
try {
|
||||
const archiveMailboxId = await this.mailboxResolverService.getArchiveMailboxId(userId);
|
||||
const { results: archiveMails, total: count } = await firstValueFrom(
|
||||
this.mailServerService.messages.listMessages(userId, archiveMailboxId, query),
|
||||
);
|
||||
|
||||
return {
|
||||
archiveMails,
|
||||
count,
|
||||
paginate: true,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to get archive messages for user ${userId}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
//==============================================
|
||||
|
||||
async getFavoriteMessages(userId: string, query: MessageListQueryDto) {
|
||||
try {
|
||||
const favoriteMailboxId = await this.mailboxResolverService.getFavoriteMailboxId(userId);
|
||||
const { results: favoriteMails, total: count } = await firstValueFrom(
|
||||
this.mailServerService.messages.listMessages(userId, favoriteMailboxId, query),
|
||||
);
|
||||
|
||||
return {
|
||||
favoriteMails,
|
||||
count,
|
||||
paginate: true,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to get junk messages for user ${userId}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================
|
||||
|
||||
async getDraftsMessages(userId: string, query: MessageListQueryDto) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user