Skip to content

Commit 7d50a4a

Browse files
authored
Merge 5760382 into b79741e
2 parents b79741e + 5760382 commit 7d50a4a

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/controllers/conversation.controller.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ exports.sendMessage = async (req, res, next) => {
221221
}
222222
};
223223

224+
exports.getNbOfMessages = async (req, res, next) => {
225+
try {
226+
const conversationId = req.params.id;
227+
Conversation.findOne({ _id: conversationId })
228+
.then(conversation => {
229+
res.send({ nb_messages: conversation.nb_messages });
230+
}).catch((error) => {
231+
next(error)
232+
});
233+
} catch (error) {
234+
next(error)
235+
}
236+
}
237+
224238

225239
exports.deleteMessage = async (req, res, next) => {
226240
try {
@@ -236,5 +250,4 @@ exports.sendVocal = async (req, res, next) => {
236250
} catch (error) {
237251
next(error)
238252
}
239-
};
240-
253+
};

src/routes/conversation.route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ router.post('/instant', verifyToken, conversationController.createInstantConvers
1313
router.post('/block', verifyToken, conversationController.BlockConversation);
1414
router.post('/unblock', verifyToken, conversationController.UnblockConversation);
1515
router.post('/report', verifyToken, conversationController.ReportConversation);
16-
16+
router.get('/:id/nb_messages', verifyToken, conversationController.getNbOfMessages);
1717

1818
// messages
1919
router.get('/message/:id', verifyToken, conversationController.getMessageConversation);

0 commit comments

Comments
 (0)