Skip to content

Commit

Permalink
feat: Added route all-chats-archived (close #194)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed May 31, 2023
1 parent 9a29514 commit 11895ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/controller/deviceController.ts
Expand Up @@ -601,6 +601,36 @@ export async function archiveAllChats(req: Request, res: Response) {
}
}

export async function getAllChatsArchiveds(req: Request, res: Response) {
/**
* #swagger.tags = ["Chat"]
* #swagger.description = 'Retrieves all archived chats.'
#swagger.autoBody=false
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters["session"] = {
schema: 'NERDWHATS_AMERICA'
}
*/
try {
const chats = await req.client.getAllChats();
const archived = [] as any;
for (const chat of chats) {
if (chat.archive === true) {
archived.push(chat);
}
}
return res.status(201).json(archived);
} catch (e) {
req.logger.error(e);
return res.status(500).json({
status: 'error',
message: 'Error on archive all chats',
error: e,
});
}
}
export async function deleteMessage(req: Request, res: Response) {
/**
* #swagger.tags = ["Messages"]
Expand Down
7 changes: 7 additions & 0 deletions src/routes/index.ts
Expand Up @@ -333,6 +333,13 @@ routes.get(
statusConnection,
DeviceController.getAllChats
);

routes.get(
'/api/:session/all-chats-archived',
verifyToken,
statusConnection,
DeviceController.getAllChatsArchiveds
);
routes.get(
'/api/:session/all-chats-with-messages',
verifyToken,
Expand Down

0 comments on commit 11895ca

Please sign in to comment.