Step 1: Creating page Messages: userlist last messages + a page for all the messages received and sent.
This commit is contained in:
@@ -67,25 +67,23 @@ router.post('/', authenticate, (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.get('/:userId/:idapp', authenticate, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
|
||||
const username = req.params.username;
|
||||
const lastdataread = req.params.lastdataread;
|
||||
const idapp = req.params.idapp;
|
||||
// var category = req.params.category;
|
||||
|
||||
tools.mylog('GET SendMsgS : ', req.params);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
if (userId !== String(req.user._id)) {
|
||||
// I'm trying to write something not mine!
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
|
||||
if (req.user.idapp !== idapp) {
|
||||
// I'm trying to get something not mine!
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_NOT_MY_USERNAME });
|
||||
}
|
||||
|
||||
// Extract all the todos of the userId only
|
||||
return SendMsg.findAllByUserIdAndIdApp(userId, idapp).then((msgall) => {
|
||||
res.send({ msgall });
|
||||
return SendMsg.findAllMsgByUsernameIdAndIdApp(username, lastdataread, idapp).then((arrmsg) => {
|
||||
|
||||
res.send({ arrmsg });
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
res.status(400).send(e);
|
||||
|
||||
Reference in New Issue
Block a user