Aggiornamento Ore
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
|
||||
Lun 13/07 ORE 23:24: 46.123.248.150: [Natasakolaric] Natasa Kolaric
|
||||
Lun 13/07 ORE 23:24: 46.123.248.150: [Natasakolaric] Natasa Kolaric
|
||||
Mar 16/03 ORE 02:00: ::1: [paolo889] Paolo889 Paolo889
|
||||
Mar 16/03 ORE 02:00: ::1: [paolo889] Paolo889 Paolo889
|
||||
Mar 16/03 ORE 02:03: : [paoloar775] Paoloar775 Paoloar775
|
||||
@@ -157,8 +157,10 @@ if (process.env.NODE_ENV === 'production') {
|
||||
host: 'https://comunitanuovomondo.app',
|
||||
portapp: '0',
|
||||
dir: '/var/www/comunitanuovomondo.app',
|
||||
// email_from: 'info.pianetalibero@gmail.com',
|
||||
// email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||
email_from: 'cnmrimini@gmail.com',
|
||||
email_pwd: 'b11837c0cfbf77b84cdbb44ecf9ee4f6b91f12599b76568e6b2b35c2bdb91291baHEPn6Q9wTgMOW29IQB3w==',
|
||||
email_pwd: '9693e200ae56f1119185a29d34079656a628f2663dc108f7d106496ac0042815F+mvJF79KcQcUnF0twoyIg==',
|
||||
telegram_key:'1646348227:AAF2qgpHB4KprhB0HPefazGLyoVGW_i4jTA',
|
||||
telegram_bot_name: 'cnm_mybot',
|
||||
pathreg_add:'_cnm',
|
||||
@@ -317,6 +319,8 @@ if (process.env.NODE_ENV === 'production') {
|
||||
host: 'https://test.comunitanuovomondo.app',
|
||||
portapp: '0',
|
||||
dir: '/var/www/test.comunitanuovomondo.app',
|
||||
// email_from: 'info.pianetalibero@gmail.com',
|
||||
// email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||
email_from: 'info.pianetalibero@gmail.com',
|
||||
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||
telegram_key:'',
|
||||
@@ -485,13 +489,13 @@ if (process.env.NODE_ENV === 'production') {
|
||||
{
|
||||
idapp: '10',
|
||||
name: 'Comunità Nuovo Mondo',
|
||||
adminemail: 'paolo.arena77@gmail.com',
|
||||
adminemail: 'cnmrimini@gmail.com',
|
||||
manageremail: '',
|
||||
host: 'http://localhost',
|
||||
portapp: '8090',
|
||||
dir: '',
|
||||
email_from: 'info.pianetalibero@gmail.com',
|
||||
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
|
||||
email_from: 'cnmrimini@gmail.com',
|
||||
email_pwd: 'bc61ab32a09d22e3a5097aa6668d3c724854c5856de9c713c427017bb89cdb0ctIESmuHr3FCNTLlRAK6d5Q',
|
||||
telegram_key: '',
|
||||
telegram_bot_name: '',
|
||||
pathreg_add:'_cnm',
|
||||
|
||||
@@ -116,6 +116,10 @@ module.exports.getHoursByIdCat = async function (idapp, userId, idCat, date_star
|
||||
};
|
||||
|
||||
module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
||||
const dateini = date;
|
||||
const datefin = tools.AddDate(date, 1);
|
||||
|
||||
|
||||
const myfind = [
|
||||
{
|
||||
$match: {
|
||||
@@ -124,16 +128,15 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
||||
hours: { $gt: 0 },
|
||||
date:
|
||||
{
|
||||
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
|
||||
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
|
||||
// $lte: new Date('2023-01-01')
|
||||
$gte: dateini,
|
||||
$lt: datefin,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
|
||||
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date", timezone: 'Europe/Rome' } },
|
||||
|
||||
totalAmount: {
|
||||
$sum: "$hours"
|
||||
@@ -151,6 +154,7 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
||||
try {
|
||||
const ris = await Hours.aggregate(myfind);
|
||||
if (ris.length > 0) {
|
||||
// console.log('[',dateini, '-', datefin, '] TOT', ris[0].totalAmount)
|
||||
return ris[0].totalAmount;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -164,7 +168,6 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
||||
|
||||
module.exports.getHoursByDate = async function (idapp, userId, date) {
|
||||
|
||||
const mystr = tools.getstrDateYYYY_MM_DD(date);
|
||||
// console.log(mystr);
|
||||
const myfind =
|
||||
{
|
||||
@@ -172,8 +175,8 @@ module.exports.getHoursByDate = async function (idapp, userId, date) {
|
||||
userId,
|
||||
hours: { $gt: 0 },
|
||||
date: {
|
||||
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
|
||||
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
|
||||
$gte: date,
|
||||
$lt: tools.AddDate(date, 1)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -134,6 +134,9 @@ var ProjectSchema = new mongoose.Schema({
|
||||
tipovisu: {
|
||||
type: Number,
|
||||
},
|
||||
view: {
|
||||
type: String,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
||||
@@ -702,6 +702,48 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) {
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.isUserResidente = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOne(myquery);
|
||||
if (!!myrec) {
|
||||
return myrec.profile.socioresidente;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.isUserVisuProjects = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOne(myquery);
|
||||
if (!!myrec) {
|
||||
return myrec.profile.socioresidente;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.isUserAlreadyQualified = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
@@ -2015,7 +2057,7 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
@@ -2034,7 +2076,7 @@ UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg" } }, count: { $sum: 1 } }
|
||||
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
@@ -2055,7 +2097,7 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
|
||||
@@ -201,7 +201,7 @@ async function ImportData(locale, idapp, strdata, settomailchimp) {
|
||||
|
||||
}
|
||||
|
||||
ris = {numadded, numtot, numalreadyexisted};
|
||||
ris = { numadded, numtot, numalreadyexisted };
|
||||
|
||||
console.log(ris);
|
||||
return ris
|
||||
@@ -349,13 +349,15 @@ router.post('/testemail', authenticate, async (req, res) => {
|
||||
|
||||
const test = false;
|
||||
|
||||
let ris = null;
|
||||
|
||||
if (test) {
|
||||
const email = 'pao.loarena77@gmail.com';
|
||||
const myuser = await User.findOne({ idapp, email });
|
||||
|
||||
const ris = await sendemail.testemailHtml(idapp, lang, email, myuser);
|
||||
ris = await sendemail.testemailHtml(idapp, lang, email, myuser);
|
||||
} else {
|
||||
const ris = await sendemail.testemail(idapp, lang, previewonly);
|
||||
ris = await sendemail.testemail(idapp, lang, previewonly);
|
||||
}
|
||||
|
||||
if (ris)
|
||||
|
||||
@@ -11,6 +11,7 @@ const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const { Project } = require('../models/project');
|
||||
const { Todo } = require('../models/todo');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -160,7 +161,6 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.query.idapp;
|
||||
|
||||
tools.mylog('GET PROJECTS : ', req.params);
|
||||
|
||||
if (!ObjectID.isValid(userId)) {
|
||||
return res.status(404).send();
|
||||
@@ -171,21 +171,28 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
|
||||
}
|
||||
|
||||
// Extract all the projects of the userId only
|
||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
// Receive the Projects only for specific Users:
|
||||
return User.isUserVisuProjects(idapp, req.user.username).then((isresidente) => {
|
||||
// Extract all the projects of the userId only
|
||||
if (!isresidente)
|
||||
return res.send({ projects: [] });
|
||||
|
||||
return objprojects
|
||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
|
||||
}).then((objprojects) => {
|
||||
return objprojects
|
||||
|
||||
res.send({ projects: objprojects.arrproj });
|
||||
}).then((objprojects) => {
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
res.send({ projects: objprojects.arrproj });
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ async function SendMsgToParam(idapp, params) {
|
||||
invia = user.profile.socioresidente;
|
||||
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
||||
invia = !user.profile.socio;
|
||||
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {
|
||||
invia = user.username === 'paoloarcnm';
|
||||
} else {
|
||||
invia = true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const _ = require('lodash');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
router.post('/load', authenticate, async (req, res) => {
|
||||
const date_start = req.body.date_start;
|
||||
let date_start = req.body.date_start;
|
||||
const date_end = req.body.date_end;
|
||||
const filter = req.body.filter;
|
||||
const idapp = req.body.idapp;
|
||||
@@ -43,8 +43,17 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
const arrhour = {};
|
||||
|
||||
let mydatets = tools.dateToEpoch(date_start)
|
||||
let mydatets_end = tools.dateToEpoch(date_end)
|
||||
// date_start = '2021-03-04T01:37:47.969Z';
|
||||
|
||||
// let mydatets = tools.dateToEpoch(date_start)
|
||||
// let mydate = new Date(tools.getstrDateYYYY_MM_DD(new Date(date_start)));
|
||||
let mydate = new Date(date_start);
|
||||
let mydatestr = mydate.toDateString();
|
||||
let mydatets = tools.dateToEpoch(mydatestr) + (new Date().getTimezoneOffset() * 60 * 1000);
|
||||
mydate = new Date(mydatets);
|
||||
let mydateyyymmdd = tools.getstrUTCDateYYYY_MM_DD(tools.AddDate(new Date(mydatestr), 1));
|
||||
|
||||
let mydatets_end = tools.dateToEpoch(date_end);
|
||||
|
||||
for (const myuser of listaResidenti) {
|
||||
arrhour[myuser.username] = [];
|
||||
@@ -55,24 +64,27 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
totalacchours[myuser.username] = 0;
|
||||
}
|
||||
|
||||
let rectotal = {};
|
||||
|
||||
|
||||
while (mydatets <= mydatets_end) {
|
||||
// console.log('mydatets', mydatets, 'mydate', mydate);
|
||||
for (const myuser of listaResidenti) {
|
||||
// for (const myproj of objprojects.arrproj) {
|
||||
//let myhours = await Hours.getHoursByIdCat(idapp, myuser._id, myproj._id, date_start, date_end);
|
||||
let mydate = new Date(mydatets);
|
||||
let rechours = await Hours.getHoursByDate(idapp, myuser._id, mydate);
|
||||
let ressum = await Hours.getTotalHoursByDate(idapp, myuser.id, mydate);
|
||||
|
||||
if (tools.isMonday(mydatets)) {
|
||||
if (tools.isMondayDate(mydate)) {
|
||||
totalacchours[myuser.username] = 0;
|
||||
}
|
||||
|
||||
if ((ressum > 0) || ((tools.isSunday(mydatets)) && totalacchours[myuser.username] > 0)) {
|
||||
if ((ressum > 0) || ((tools.isSundayDate(mydate)) && totalacchours[myuser.username] > 0)) {
|
||||
totalacchours[myuser.username] = totalacchours[myuser.username] + ressum;
|
||||
const rectotal = {
|
||||
rectotal = {
|
||||
totalhours: ressum,
|
||||
totalacchours: 0,
|
||||
date: tools.getstrDateYYYY_MM_DD(mydate),
|
||||
date: mydateyyymmdd,
|
||||
}
|
||||
|
||||
if (tools.isSunday(mydatets)) {
|
||||
@@ -108,7 +120,7 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
colors.themebgcolor = myproj.themebgcolor;
|
||||
colors.themecolor = myproj.themecolor;
|
||||
}
|
||||
if (!colors.themebgcolor) {
|
||||
if (!colors.themebgcolor || colors.themebgcolor === 'white') {
|
||||
if (myproj) {
|
||||
colors = await Project.findColorsByProject(myproj._id);
|
||||
}
|
||||
@@ -128,7 +140,15 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// console.log('mydatestr', mydatestr, 'mydateyyymmdd', mydateyyymmdd)
|
||||
// if (!!rectotal)
|
||||
// console.log('TOT', rectotal.totalacchours);
|
||||
|
||||
mydatets += 86400000;
|
||||
mydate = tools.AddDate(mydate, 1);
|
||||
mydatestr = mydate.toDateString();
|
||||
mydateyyymmdd = tools.getstrUTCDateYYYY_MM_DD(tools.AddDate(new Date(mydatestr), 1));
|
||||
}
|
||||
|
||||
return res.send({ listaResidenti, arrhour });
|
||||
|
||||
@@ -94,15 +94,17 @@ router.post('/', async (req, res) => {
|
||||
// Controlla se anche l'ultimo record era dallo stesso IP:
|
||||
const lastrec = await User.getLastRec(body.idapp);
|
||||
if (!!lastrec) {
|
||||
if (lastrec.ipaddr === user.ipaddr) {
|
||||
// Se l'ha fatto troppo ravvicinato
|
||||
if (lastrec.date_reg) {
|
||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||
if (ris) {
|
||||
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
||||
await tools.snooze(10000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
||||
return 1;
|
||||
if (process.env.LOCALE !== "1") {
|
||||
if (lastrec.ipaddr === user.ipaddr) {
|
||||
// Se l'ha fatto troppo ravvicinato
|
||||
if (lastrec.date_reg) {
|
||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||
if (ris) {
|
||||
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
||||
await tools.snooze(10000);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,9 +281,9 @@ router.post('/', async (req, res) => {
|
||||
// Invia un'email all'utente
|
||||
// tools.mylog('process.env.TESTING_ON', process.env.TESTING_ON);
|
||||
console.log('res.locale', res.locale);
|
||||
if (!tools.testing()) {
|
||||
// if (!tools.testing()) {
|
||||
await sendemail.sendEmail_Registration(user.lang, user.email, user, user.idapp, user.linkreg);
|
||||
}
|
||||
// }
|
||||
res.header('x-auth', token).send(user);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -67,6 +67,8 @@ module.exports = {
|
||||
if (transport) {
|
||||
paramemail.transport = transport;
|
||||
} else {
|
||||
paramemail.transport = this.getTransport(mylocalsconf);
|
||||
/*
|
||||
// console.log('1b . transport gmail');
|
||||
paramemail.transport = {
|
||||
service: 'gmail',
|
||||
@@ -74,9 +76,11 @@ module.exports = {
|
||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// console.table(paramemail.transport);
|
||||
|
||||
// console.log('2 . paramemail.transport', paramemail.transport);
|
||||
// console.log('user', tools.getEmailByIdApp(mylocalsconf.idapp));
|
||||
// console.log('pass', tools.getPwdByIdApp(mylocalsconf.idapp));
|
||||
@@ -150,18 +154,18 @@ module.exports = {
|
||||
// },
|
||||
|
||||
getlinkReg: function (idapp, idreg) {
|
||||
strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `?idapp=${idapp}&idlink=${idreg}`;
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `?idapp=${idapp}&idlink=${idreg}`;
|
||||
return strlinkreg;
|
||||
},
|
||||
getlinkRequestNewPassword: function (idapp, email, tokenforgot) {
|
||||
strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD + `?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD + `?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
|
||||
return strlinkreg;
|
||||
},
|
||||
sendEmail_Registration: async function (lang, emailto, user, idapp, idreg) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
mylocalsconf = {
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
@@ -183,13 +187,15 @@ module.exports = {
|
||||
|
||||
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
|
||||
|
||||
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' . name + ' ' + surname + ' (' + username + ')');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
},
|
||||
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
|
||||
|
||||
mylocalsconf = {
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
@@ -210,7 +216,7 @@ module.exports = {
|
||||
tools.mylog('sendEmail_Booking');
|
||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||
|
||||
mylocalsconf = {
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
@@ -262,7 +268,7 @@ module.exports = {
|
||||
|
||||
tools.mylog('sendEmail_CancelBooking');
|
||||
|
||||
mylocalsconf = {
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
@@ -455,7 +461,7 @@ module.exports = {
|
||||
const baseurl = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||
const urlunsibscribe = baseurl + '/unsubscribe?em=' + mylocalsconf.hashemail + '&mc=' + mylocalsconf.dataemail.mailchimpactive + '&email=' + mylocalsconf.emailto;
|
||||
|
||||
out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||
out = out.replace('{email}', mylocalsconf.emailto);
|
||||
out = out.replace('{name}', mylocalsconf.name);
|
||||
out = out.replace('{surname}', mylocalsconf.surname);
|
||||
@@ -465,9 +471,9 @@ module.exports = {
|
||||
|
||||
replacefields: function (mylocalsconf) {
|
||||
try {
|
||||
mylocalsconf.dataemail.disclaimer_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer);
|
||||
mylocalsconf.dataemail.disc_bottom_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom);
|
||||
mylocalsconf.dataemail.templ.testoheadermail_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.templ.testoheadermail);
|
||||
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer) : '';
|
||||
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom) : '';
|
||||
mylocalsconf.dataemail.templ.testoheadermail_out = !!mylocalsconf.dataemail.templ.testoheadermail ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.templ.testoheadermail) : '';
|
||||
} catch (e) {
|
||||
console.error('Error replacefields: ' + e)
|
||||
}
|
||||
@@ -515,12 +521,14 @@ module.exports = {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
host: mylocalsconf.dataemail.email_service,
|
||||
port: mylocalsconf.dataemail.email_port,
|
||||
secureConnection: false,
|
||||
tls: {cipher:'SSLv3'},
|
||||
auth: {
|
||||
user: mylocalsconf.dataemail.from,
|
||||
pass: mylocalsconf.dataemail.pwd_from
|
||||
}
|
||||
});
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail' && mylocalsconf.dataemail.email_service !== undefined) {
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail' && !!mylocalsconf.dataemail.pwd_from) {
|
||||
|
||||
//smtpTransport = {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
@@ -587,7 +595,7 @@ module.exports = {
|
||||
if (secpause < process.env.DELAY_SENDEMAIL)
|
||||
secpause = process.env.DELAY_SENDEMAIL;
|
||||
|
||||
activate = await Newstosent.isActivated(id_newstosent);
|
||||
const activate = await Newstosent.isActivated(id_newstosent);
|
||||
|
||||
if (!activate) {
|
||||
// Invio Newsletter Abortito!
|
||||
@@ -658,7 +666,7 @@ module.exports = {
|
||||
|
||||
} catch (e) {
|
||||
|
||||
activate = await Newstosent.isActivated(id_newstosent);
|
||||
const activate = await Newstosent.isActivated(id_newstosent);
|
||||
|
||||
if (!activate) {
|
||||
// Invio Newsletter Abortito!
|
||||
@@ -698,7 +706,7 @@ module.exports = {
|
||||
sendNewsletter: async function (rec, idapp) {
|
||||
if (rec) {
|
||||
// Start the job
|
||||
myjobnews = await Newstosent.findOne({ _id: rec._id });
|
||||
let myjobnews = await Newstosent.findOne({ _id: rec._id });
|
||||
if (!!myjobnews) {
|
||||
myjobnews.starting_job = true;
|
||||
myjobnews.datestartJob = new Date();
|
||||
@@ -748,8 +756,8 @@ module.exports = {
|
||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||
|
||||
|
||||
mytitle = 'Prova msg'
|
||||
messaggio = '<br><b>Ciao!</b><div>Come stai?</div><br>Tutto Bene?<br><a href="https://ayni.gifteconomy.app/">Prova Link</a><br><i>Corsivo</i></i> ';
|
||||
let mytitle = 'Prova msg'
|
||||
let messaggio = '<br><b>Ciao!</b><div>Come stai?</div><br>Tutto Bene?<br><a href="https://ayni.gifteconomy.app/">Prova Link</a><br><i>Corsivo</i></i> ';
|
||||
|
||||
/*const htmlToText = require('html-to-text');
|
||||
|
||||
|
||||
@@ -195,6 +195,8 @@ if ((process.env.NODE_ENV === 'production') || (process.env.NODE_ENV === 'test')
|
||||
|
||||
if (process.env.PROD !== 1) {
|
||||
testmsgwebpush();
|
||||
|
||||
// tools.sendNotifToAdmin('Riparti', 'Riparti');
|
||||
// sendemail.testemail('2', 'it');
|
||||
|
||||
let miapass = '';
|
||||
@@ -300,6 +302,7 @@ function testmsgwebpush() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Cron every X minutes
|
||||
cron.schedule('*/2 * * * *', () => {
|
||||
// console.log('Running Cron Job');
|
||||
|
||||
@@ -633,7 +633,7 @@ module.exports = {
|
||||
allfieldProject: function () {
|
||||
return ['idapp', 'userId', 'respUsername', 'viceRespUsername', 'pos', 'typeproj', 'id_main_project', 'id_parent', 'descr', 'longdescr', 'groupId', 'hoursplanned', 'hoursleft', 'themecolor', 'themebgcolor', 'hoursworked', 'priority', 'statusproj', 'created_at', 'modify_at',
|
||||
'completed_at', 'expiring_at', 'enableExpiring', 'progressCalc', 'modified', 'live_url', 'test_url', 'begin_development', 'begin_test', 'totalphases', 'actualphase', 'hoursweeky_plannedtowork', 'endwork_estimate'
|
||||
, 'privacyread', 'privacywrite', 'tipovisu']
|
||||
, 'privacyread', 'privacywrite', 'tipovisu', 'view']
|
||||
},
|
||||
|
||||
allfieldBooking: function () {
|
||||
@@ -841,7 +841,28 @@ module.exports = {
|
||||
},
|
||||
*/
|
||||
|
||||
sendNotifToAdmin(title, msg, tag = '') {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
|
||||
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
|
||||
|
||||
User.find({ username: 'paoloarcnm' }).then((arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
this.sendNotificationToUser(user._id, title, msg, '/', '', tag, [])
|
||||
.then(ris => {
|
||||
if (ris) {
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
checkUserOk(userpassed, userauth, res) {
|
||||
this.mylog('checkUserOk', userpassed, userauth);
|
||||
@@ -1379,6 +1400,16 @@ module.exports = {
|
||||
return dayOfWeek === 1
|
||||
},
|
||||
|
||||
isSundayDate(mydate) {
|
||||
const dayOfWeek = mydate.getDay()
|
||||
return dayOfWeek === 0
|
||||
},
|
||||
|
||||
isMondayDate(mydate) {
|
||||
const dayOfWeek = mydate.getDay()
|
||||
return dayOfWeek === 1
|
||||
},
|
||||
|
||||
getWeekDayByLang(date, lang) {
|
||||
return this.getWeekDayByLangByNumCar(date, lang, 3)
|
||||
},
|
||||
@@ -1425,6 +1456,15 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
getstrUTCDateYYYY_MM_DD(mydate) {
|
||||
if (mydate) {
|
||||
// console.log('getstrDate', mytimestamp)
|
||||
return mydate.getUTCFullYear() + '-' + this.appendLeadingZeroes(mydate.getUTCMonth() + 1) + '-' + this.appendLeadingZeroes(mydate.getUTCDate())
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
getstrDateLong(mydate, lang) {
|
||||
if (mydate) {
|
||||
// console.log('getstrDate', mytimestamp)
|
||||
|
||||
@@ -48,7 +48,8 @@ module.exports = {
|
||||
SEND_TO_ALL: 1,
|
||||
SEND_TO_SOCI: 2,
|
||||
SEND_TO_SOCIO_RESIDENTE: 3,
|
||||
SEND_TO_NON_SOCI: 10
|
||||
SEND_TO_NON_SOCI: 10,
|
||||
SEND_TO_PAOLO: 20
|
||||
},
|
||||
|
||||
TypeMsg_Actions: {
|
||||
|
||||
Reference in New Issue
Block a user