- Delete Event with ask confirmation
- Fix dateStart only 1 view if is the same day - Sending a message from the Event Page: to a user or to a "Event" - Add button "Ask Info" - Starting view msg into the messagepopup component
This commit is contained in:
@@ -16,6 +16,7 @@ const { Operator } = require('../models/operator');
|
||||
const { Where } = require('../models/where');
|
||||
const { MyEvent } = require('../models/myevent');
|
||||
const { Contribtype } = require('../models/contribtype');
|
||||
const { SendMsg } = require('../models/sendmsg');
|
||||
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -86,42 +87,6 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
router.get(process.env.LINK_CHECK_UPDATES, authenticate, (req, res) => {
|
||||
const userId = req.user._id;
|
||||
|
||||
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
cfgserver.find().then((arrcfgrec) => {
|
||||
|
||||
if (!arrcfgrec)
|
||||
return res.status(404).send();
|
||||
|
||||
// ++Todo: Add to Log Stat ....
|
||||
|
||||
if (req.user) {
|
||||
// If User is Admin, then send user Lists
|
||||
if (User.isAdmin(req.user)) {
|
||||
// Send UsersList
|
||||
return User.getUsersList(req.user.idapp).then(usersList => {
|
||||
return res.send({ cfgServer: arrcfgrec, usersList });
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
res.send({ cfgServer: arrcfgrec });
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Invio la Nuova Password richiesta dal reset!
|
||||
// Ritorna il token per poter effettuare le chiamate...
|
||||
router.post(process.env.LINK_UPDATE_PASSWORD, (req, res) => {
|
||||
@@ -165,6 +130,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = Booking;
|
||||
else if (tablename === 'operators')
|
||||
mytable = Operator;
|
||||
else if (tablename === 'sendmsgs')
|
||||
mytable = SendMsg;
|
||||
else if (tablename === 'wheres')
|
||||
mytable = Where;
|
||||
else if (tablename === 'myevents')
|
||||
@@ -335,9 +302,10 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
const sall = req.params.sall;
|
||||
// var category = req.params.category;
|
||||
|
||||
tools.mylog('loadsite : ', req.params);
|
||||
// tools.mylog('loadsite : ', req.params);
|
||||
|
||||
let bookedevent = [];
|
||||
let msgs = [];
|
||||
|
||||
if (userId !== '0') {
|
||||
// LOGGED WITH USERID
|
||||
@@ -350,10 +318,16 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
const wheres = Where.findAllIdApp(idapp);
|
||||
const contribtype = Contribtype.findAllIdApp(idapp);
|
||||
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype])
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, msgs])
|
||||
.then((arrdata) => {
|
||||
console.table(arrdata);
|
||||
res.send({ bookedevent: arrdata[0], eventlist: arrdata[1], operators: arrdata[2], wheres: arrdata[3], contribtype: arrdata[4] });
|
||||
// console.table(arrdata);
|
||||
res.send({
|
||||
bookedevent: arrdata[0],
|
||||
eventlist: arrdata[1],
|
||||
operators: arrdata[2],
|
||||
wheres: arrdata[3],
|
||||
contribtype: arrdata[4],
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
@@ -362,5 +336,52 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
|
||||
});
|
||||
|
||||
router.get(process.env.LINK_CHECK_UPDATES, authenticate, (req, res) => {
|
||||
const userId = req.user._id;
|
||||
|
||||
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
cfgserver.find().then((arrcfgrec) => {
|
||||
|
||||
if (!arrcfgrec)
|
||||
return res.status(404).send();
|
||||
|
||||
// ++Todo: Add to Log Stat ....
|
||||
|
||||
// const sall = '0';
|
||||
|
||||
msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
|
||||
|
||||
let usersList = null;
|
||||
|
||||
if (req.user) {
|
||||
// If User is Admin, then send user Lists
|
||||
if (User.isAdmin(req.user)) {
|
||||
// Send UsersList
|
||||
usersList = User.getUsersList(req.user.idapp)
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all([usersList, msgs])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
return res.send({
|
||||
cfgServer: arrcfgrec,
|
||||
usersList: arrdata[0],
|
||||
msgs: arrdata[1],
|
||||
});
|
||||
});
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -101,7 +101,7 @@ router.get('/:userId/:idapp/:sall', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
// Extract all the todos of the userId only
|
||||
MyEvent.findAllByUserIdAndIdApp(userId, idapp, sall).then((recevent) => {
|
||||
return MyEvent.findAllByUserIdAndIdApp(userId, idapp, sall).then((recevent) => {
|
||||
res.send({ recevent });
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
|
||||
@@ -6,7 +6,8 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const { Sendmsg } = require('../models/Sendmsg');
|
||||
const { Operator } = require('../models/operator');
|
||||
const { SendMsg } = require('../models/sendmsg');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
@@ -14,37 +15,55 @@ const sendemail = require('../sendemail');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
function sendNotif(res, idapp, user, recmsg) {
|
||||
async function sendNotif(res, idapp, user, recmsg) {
|
||||
//++Todo: tools.sendNotificationToUser
|
||||
|
||||
// Send Msg
|
||||
sendemail.sendEmail_Msg(res, user.lang, user.email, user, idapp, recmsg);
|
||||
// Extract the Email Destination
|
||||
const emaildest = await Operator.getEmailByUsername(recmsg.dest.idapp, recmsg.dest.username);
|
||||
console.log('emaildest', emaildest);
|
||||
|
||||
// Send Msg by EMAIL
|
||||
if (emaildest)
|
||||
return await sendemail.sendEmail_Msg(res, user.lang, emaildest, user, idapp, recmsg);
|
||||
|
||||
}
|
||||
|
||||
router.post('/', authenticate, (req, res) => {
|
||||
tools.mylog('INIZIO - Sendmsg');
|
||||
tools.mylog('INIZIO - SendMsg');
|
||||
// tools.mylog('req.body', req.body);
|
||||
const body = _.pick(req.body, tools.allfieldSendmsg());
|
||||
const body = _.pick(req.body, tools.allfieldSendMsg());
|
||||
|
||||
tools.mylog('crea Sendmsg');
|
||||
const Sendmsg = new Sendmsg(body);
|
||||
tools.mylog('crea SendMsg');
|
||||
const myrecmsg = new SendMsg(body);
|
||||
|
||||
const check = tools.checkUserOk(Sendmsg.userId, req.user._id);
|
||||
const check = tools.checkUserOk(myrecmsg.origin.userId, req.user._id);
|
||||
if (check.exit) return check.ret;
|
||||
|
||||
// console.log('fieldtochange', fieldtochange);
|
||||
|
||||
Sendmsg._id = new ObjectID();
|
||||
return Sendmsg.save().then((writeresult) => {
|
||||
let idobj = writeresult._id;
|
||||
myrecmsg._id = new ObjectID();
|
||||
return myrecmsg.save()
|
||||
.then((writeresult) => {
|
||||
let idobj = writeresult._id;
|
||||
|
||||
Sendmsg.findById(idobj)
|
||||
.then((recmsg) => {
|
||||
sendNotif(res, body.idapp, req.user, recmsg);
|
||||
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
|
||||
});
|
||||
});
|
||||
myrecmsg._id = idobj;
|
||||
|
||||
return SendMsg.findById(idobj)
|
||||
.then((recmsg) => {
|
||||
// Add this field because I don't want to add into the database
|
||||
recmsg.origin.infoevent = body.origin.infoevent;
|
||||
|
||||
return sendNotif(res, body.idapp, req.user, recmsg).then((ris) => {
|
||||
if (ris)
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
|
||||
else
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
|
||||
})
|
||||
});
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
res.status(400).send(e);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
@@ -53,7 +72,7 @@ router.get('/:userId/:idapp', authenticate, (req, res) => {
|
||||
const idapp = req.params.idapp;
|
||||
// var category = req.params.category;
|
||||
|
||||
tools.mylog('GET SendmsgS : ', req.params);
|
||||
tools.mylog('GET SendMsgS : ', req.params);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
@@ -65,7 +84,7 @@ router.get('/:userId/:idapp', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
// Extract all the todos of the userId only
|
||||
Sendmsg.findAllByUserIdAndIdApp(userId, idapp).then((msgall) => {
|
||||
return SendMsg.findAllByUserIdAndIdApp(userId, idapp).then((msgall) => {
|
||||
res.send({ msgall });
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
|
||||
Reference in New Issue
Block a user