feat: Adds method to fetch contacts with last message

- Implements the `fetchContactsWithLastMessage` method in `ChatController` to retrieve contacts and their last messages.
- Updates `ChatRouter` to include the new route that calls the above method.
- Adds logic in `ChannelStartupService` to fetch contacts and their last messages, improving contact management functionality.
This commit is contained in:
Davidson Gomes
2025-05-12 12:48:05 -03:00
parent 86c603b3a1
commit cee6498ea0
4 changed files with 55 additions and 2 deletions

View File

@@ -253,6 +253,23 @@ export class ChatRouter extends RouterBroker {
return res.status(HttpStatus.OK).json(response);
})
.get(this.routerPath('fetchContactsWithLastMessage'), ...guards, async (req, res) => {
logger.verbose('request received in fetchContactsWithLastMessage');
logger.verbose('request body: ');
logger.verbose(req.body);
logger.verbose('request query: ');
logger.verbose(req.query);
const response = await this.dataValidate<InstanceDto>({
request: req,
schema: null,
ClassRef: InstanceDto,
execute: (instance) => chatController.fetchContactsWithLastMessage(instance),
});
return res.status(HttpStatus.OK).json(response);
})
.post(this.routerPath('sendPresence'), ...guards, async (req, res) => {
logger.verbose('request received in sendPresence');
logger.verbose('request body: ');