Notifiche - Tutti - non letti

This commit is contained in:
Paolo Arena
2022-07-21 00:21:03 +02:00
parent cbd65ccdbe
commit e9ce597027
10 changed files with 235 additions and 177 deletions

View File

@@ -16,36 +16,10 @@ const sendemail = require('../sendemail');
const shared_consts = require('../tools/shared_nodejs');
const globalTables = require('../tools/globalTables');
const _ = require('lodash');
function checkifSendPushNotification() {
return process.env.ENABLE_PUSHNOTIFICATION === "1";
//return false;
}
async function sendNotif(res, idapp, user, recmsg) {
if (tools.isBitActive(recmsg.options, shared_consts.MessageOptions.Notify_ByPushNotification)) {
if (this.checkifSendPushNotification) {
console.log('SEND PUSH NOTIFICATION ')
//++Todo: tools.sendNotificationToUser
}
}
// Read from the operator table first
let emaildest = await Operator.getEmailByUsername(recmsg.dest.idapp, recmsg.dest.username);
if (!emaildest)
emaildest = await User.getEmailByUsername(recmsg.dest.idapp, recmsg.dest.username);
console.log('emaildest', emaildest);
// Send Msg by EMAIL
if (emaildest && tools.isBitActive(recmsg.options, shared_consts.MessageOptions.Notify_ByEmail))
await sendemail.sendEmail_Msg(res, user.lang, emaildest, user, idapp, recmsg);
return true
}
router.post('/', authenticate, (req, res) => {
tools.mylog('INIZIO - SendMsg');
@@ -72,7 +46,7 @@ router.post('/', authenticate, (req, res) => {
// Add this field because I don't want to add into the database
recmsg.source.infoevent = body.source.infoevent;
return await sendNotif(res, body.idapp, req.user, recmsg).then((ris) => {
return await globalTables.sendNotif(res, body.idapp, req.user, recmsg).then((ris) => {
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
})
});