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',
|
host: 'https://comunitanuovomondo.app',
|
||||||
portapp: '0',
|
portapp: '0',
|
||||||
dir: '/var/www/comunitanuovomondo.app',
|
dir: '/var/www/comunitanuovomondo.app',
|
||||||
|
// email_from: 'info.pianetalibero@gmail.com',
|
||||||
|
// email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||||
email_from: 'cnmrimini@gmail.com',
|
email_from: 'cnmrimini@gmail.com',
|
||||||
email_pwd: 'b11837c0cfbf77b84cdbb44ecf9ee4f6b91f12599b76568e6b2b35c2bdb91291baHEPn6Q9wTgMOW29IQB3w==',
|
email_pwd: '9693e200ae56f1119185a29d34079656a628f2663dc108f7d106496ac0042815F+mvJF79KcQcUnF0twoyIg==',
|
||||||
telegram_key:'1646348227:AAF2qgpHB4KprhB0HPefazGLyoVGW_i4jTA',
|
telegram_key:'1646348227:AAF2qgpHB4KprhB0HPefazGLyoVGW_i4jTA',
|
||||||
telegram_bot_name: 'cnm_mybot',
|
telegram_bot_name: 'cnm_mybot',
|
||||||
pathreg_add:'_cnm',
|
pathreg_add:'_cnm',
|
||||||
@@ -317,6 +319,8 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
host: 'https://test.comunitanuovomondo.app',
|
host: 'https://test.comunitanuovomondo.app',
|
||||||
portapp: '0',
|
portapp: '0',
|
||||||
dir: '/var/www/test.comunitanuovomondo.app',
|
dir: '/var/www/test.comunitanuovomondo.app',
|
||||||
|
// email_from: 'info.pianetalibero@gmail.com',
|
||||||
|
// email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||||
email_from: 'info.pianetalibero@gmail.com',
|
email_from: 'info.pianetalibero@gmail.com',
|
||||||
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
|
||||||
telegram_key:'',
|
telegram_key:'',
|
||||||
@@ -485,13 +489,13 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
{
|
{
|
||||||
idapp: '10',
|
idapp: '10',
|
||||||
name: 'Comunità Nuovo Mondo',
|
name: 'Comunità Nuovo Mondo',
|
||||||
adminemail: 'paolo.arena77@gmail.com',
|
adminemail: 'cnmrimini@gmail.com',
|
||||||
manageremail: '',
|
manageremail: '',
|
||||||
host: 'http://localhost',
|
host: 'http://localhost',
|
||||||
portapp: '8090',
|
portapp: '8090',
|
||||||
dir: '',
|
dir: '',
|
||||||
email_from: 'info.pianetalibero@gmail.com',
|
email_from: 'cnmrimini@gmail.com',
|
||||||
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
|
email_pwd: 'bc61ab32a09d22e3a5097aa6668d3c724854c5856de9c713c427017bb89cdb0ctIESmuHr3FCNTLlRAK6d5Q',
|
||||||
telegram_key: '',
|
telegram_key: '',
|
||||||
telegram_bot_name: '',
|
telegram_bot_name: '',
|
||||||
pathreg_add:'_cnm',
|
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) {
|
module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
||||||
|
const dateini = date;
|
||||||
|
const datefin = tools.AddDate(date, 1);
|
||||||
|
|
||||||
|
|
||||||
const myfind = [
|
const myfind = [
|
||||||
{
|
{
|
||||||
$match: {
|
$match: {
|
||||||
@@ -124,16 +128,15 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
|||||||
hours: { $gt: 0 },
|
hours: { $gt: 0 },
|
||||||
date:
|
date:
|
||||||
{
|
{
|
||||||
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
|
$gte: dateini,
|
||||||
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
|
$lt: datefin,
|
||||||
// $lte: new Date('2023-01-01')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$group:
|
$group:
|
||||||
{
|
{
|
||||||
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
|
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date", timezone: 'Europe/Rome' } },
|
||||||
|
|
||||||
totalAmount: {
|
totalAmount: {
|
||||||
$sum: "$hours"
|
$sum: "$hours"
|
||||||
@@ -151,6 +154,7 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
|||||||
try {
|
try {
|
||||||
const ris = await Hours.aggregate(myfind);
|
const ris = await Hours.aggregate(myfind);
|
||||||
if (ris.length > 0) {
|
if (ris.length > 0) {
|
||||||
|
// console.log('[',dateini, '-', datefin, '] TOT', ris[0].totalAmount)
|
||||||
return ris[0].totalAmount;
|
return ris[0].totalAmount;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -164,7 +168,6 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
|
|||||||
|
|
||||||
module.exports.getHoursByDate = async function (idapp, userId, date) {
|
module.exports.getHoursByDate = async function (idapp, userId, date) {
|
||||||
|
|
||||||
const mystr = tools.getstrDateYYYY_MM_DD(date);
|
|
||||||
// console.log(mystr);
|
// console.log(mystr);
|
||||||
const myfind =
|
const myfind =
|
||||||
{
|
{
|
||||||
@@ -172,8 +175,8 @@ module.exports.getHoursByDate = async function (idapp, userId, date) {
|
|||||||
userId,
|
userId,
|
||||||
hours: { $gt: 0 },
|
hours: { $gt: 0 },
|
||||||
date: {
|
date: {
|
||||||
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
|
$gte: date,
|
||||||
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
|
$lt: tools.AddDate(date, 1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ var ProjectSchema = new mongoose.Schema({
|
|||||||
tipovisu: {
|
tipovisu: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
view: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
deleted: {
|
deleted: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -702,6 +702,48 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) {
|
|||||||
return !!myrec;
|
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) {
|
UserSchema.statics.isUserAlreadyQualified = async function (idapp, username) {
|
||||||
const User = this;
|
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 }
|
$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 }
|
$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 }
|
$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);
|
console.log(ris);
|
||||||
return ris
|
return ris
|
||||||
@@ -349,13 +349,15 @@ router.post('/testemail', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
const test = false;
|
const test = false;
|
||||||
|
|
||||||
|
let ris = null;
|
||||||
|
|
||||||
if (test) {
|
if (test) {
|
||||||
const email = 'pao.loarena77@gmail.com';
|
const email = 'pao.loarena77@gmail.com';
|
||||||
const myuser = await User.findOne({ idapp, email });
|
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 {
|
} else {
|
||||||
const ris = await sendemail.testemail(idapp, lang, previewonly);
|
ris = await sendemail.testemail(idapp, lang, previewonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ris)
|
if (ris)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const { authenticate } = require('../middleware/authenticate');
|
|||||||
|
|
||||||
const { Project } = require('../models/project');
|
const { Project } = require('../models/project');
|
||||||
const { Todo } = require('../models/todo');
|
const { Todo } = require('../models/todo');
|
||||||
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
@@ -160,7 +161,6 @@ router.get('/:userId', authenticate, (req, res) => {
|
|||||||
const userId = req.params.userId;
|
const userId = req.params.userId;
|
||||||
const idapp = req.query.idapp;
|
const idapp = req.query.idapp;
|
||||||
|
|
||||||
tools.mylog('GET PROJECTS : ', req.params);
|
|
||||||
|
|
||||||
if (!ObjectID.isValid(userId)) {
|
if (!ObjectID.isValid(userId)) {
|
||||||
return res.status(404).send();
|
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 });
|
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract all the projects of the userId only
|
// Receive the Projects only for specific Users:
|
||||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
return User.isUserVisuProjects(idapp, req.user.username).then((isresidente) => {
|
||||||
if (!!objprojects.arrproj)
|
// Extract all the projects of the userId only
|
||||||
tools.mylog('projects', objprojects.arrproj.length);
|
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) => {
|
res.send({ projects: objprojects.arrproj });
|
||||||
console.log(e.message);
|
|
||||||
res.status(400).send(e);
|
}).catch((e) => {
|
||||||
});
|
console.log(e.message);
|
||||||
|
res.status(400).send(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ async function SendMsgToParam(idapp, params) {
|
|||||||
invia = user.profile.socioresidente;
|
invia = user.profile.socioresidente;
|
||||||
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
||||||
invia = !user.profile.socio;
|
invia = !user.profile.socio;
|
||||||
|
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {
|
||||||
|
invia = user.username === 'paoloarcnm';
|
||||||
} else {
|
} else {
|
||||||
invia = true;
|
invia = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const _ = require('lodash');
|
|||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
router.post('/load', authenticate, async (req, res) => {
|
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 date_end = req.body.date_end;
|
||||||
const filter = req.body.filter;
|
const filter = req.body.filter;
|
||||||
const idapp = req.body.idapp;
|
const idapp = req.body.idapp;
|
||||||
@@ -43,8 +43,17 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
const arrhour = {};
|
const arrhour = {};
|
||||||
|
|
||||||
let mydatets = tools.dateToEpoch(date_start)
|
// date_start = '2021-03-04T01:37:47.969Z';
|
||||||
let mydatets_end = tools.dateToEpoch(date_end)
|
|
||||||
|
// 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) {
|
for (const myuser of listaResidenti) {
|
||||||
arrhour[myuser.username] = [];
|
arrhour[myuser.username] = [];
|
||||||
@@ -55,24 +64,27 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
totalacchours[myuser.username] = 0;
|
totalacchours[myuser.username] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rectotal = {};
|
||||||
|
|
||||||
|
|
||||||
while (mydatets <= mydatets_end) {
|
while (mydatets <= mydatets_end) {
|
||||||
|
// console.log('mydatets', mydatets, 'mydate', mydate);
|
||||||
for (const myuser of listaResidenti) {
|
for (const myuser of listaResidenti) {
|
||||||
// for (const myproj of objprojects.arrproj) {
|
// for (const myproj of objprojects.arrproj) {
|
||||||
//let myhours = await Hours.getHoursByIdCat(idapp, myuser._id, myproj._id, date_start, date_end);
|
//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 rechours = await Hours.getHoursByDate(idapp, myuser._id, mydate);
|
||||||
let ressum = await Hours.getTotalHoursByDate(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;
|
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;
|
totalacchours[myuser.username] = totalacchours[myuser.username] + ressum;
|
||||||
const rectotal = {
|
rectotal = {
|
||||||
totalhours: ressum,
|
totalhours: ressum,
|
||||||
totalacchours: 0,
|
totalacchours: 0,
|
||||||
date: tools.getstrDateYYYY_MM_DD(mydate),
|
date: mydateyyymmdd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tools.isSunday(mydatets)) {
|
if (tools.isSunday(mydatets)) {
|
||||||
@@ -108,7 +120,7 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
colors.themebgcolor = myproj.themebgcolor;
|
colors.themebgcolor = myproj.themebgcolor;
|
||||||
colors.themecolor = myproj.themecolor;
|
colors.themecolor = myproj.themecolor;
|
||||||
}
|
}
|
||||||
if (!colors.themebgcolor) {
|
if (!colors.themebgcolor || colors.themebgcolor === 'white') {
|
||||||
if (myproj) {
|
if (myproj) {
|
||||||
colors = await Project.findColorsByProject(myproj._id);
|
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;
|
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 });
|
return res.send({ listaResidenti, arrhour });
|
||||||
|
|||||||
@@ -94,15 +94,17 @@ router.post('/', async (req, res) => {
|
|||||||
// Controlla se anche l'ultimo record era dallo stesso IP:
|
// Controlla se anche l'ultimo record era dallo stesso IP:
|
||||||
const lastrec = await User.getLastRec(body.idapp);
|
const lastrec = await User.getLastRec(body.idapp);
|
||||||
if (!!lastrec) {
|
if (!!lastrec) {
|
||||||
if (lastrec.ipaddr === user.ipaddr) {
|
if (process.env.LOCALE !== "1") {
|
||||||
// Se l'ha fatto troppo ravvicinato
|
if (lastrec.ipaddr === user.ipaddr) {
|
||||||
if (lastrec.date_reg) {
|
// Se l'ha fatto troppo ravvicinato
|
||||||
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
if (lastrec.date_reg) {
|
||||||
if (ris) {
|
let ris = tools.isdiffSecDateLess(lastrec.date_reg, 120);
|
||||||
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
if (ris) {
|
||||||
await tools.snooze(10000);
|
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
|
||||||
res.status(400).send({ code: server_constants.RIS_CODE_BANIP, msg: '' });
|
await tools.snooze(10000);
|
||||||
return 1;
|
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
|
// Invia un'email all'utente
|
||||||
// tools.mylog('process.env.TESTING_ON', process.env.TESTING_ON);
|
// tools.mylog('process.env.TESTING_ON', process.env.TESTING_ON);
|
||||||
console.log('res.locale', res.locale);
|
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);
|
await sendemail.sendEmail_Registration(user.lang, user.email, user, user.idapp, user.linkreg);
|
||||||
}
|
// }
|
||||||
res.header('x-auth', token).send(user);
|
res.header('x-auth', token).send(user);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ module.exports = {
|
|||||||
if (transport) {
|
if (transport) {
|
||||||
paramemail.transport = transport;
|
paramemail.transport = transport;
|
||||||
} else {
|
} else {
|
||||||
|
paramemail.transport = this.getTransport(mylocalsconf);
|
||||||
|
/*
|
||||||
// console.log('1b . transport gmail');
|
// console.log('1b . transport gmail');
|
||||||
paramemail.transport = {
|
paramemail.transport = {
|
||||||
service: 'gmail',
|
service: 'gmail',
|
||||||
@@ -74,9 +76,11 @@ module.exports = {
|
|||||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.table(paramemail.transport);
|
||||||
|
|
||||||
// console.log('2 . paramemail.transport', paramemail.transport);
|
// console.log('2 . paramemail.transport', paramemail.transport);
|
||||||
// console.log('user', tools.getEmailByIdApp(mylocalsconf.idapp));
|
// console.log('user', tools.getEmailByIdApp(mylocalsconf.idapp));
|
||||||
// console.log('pass', tools.getPwdByIdApp(mylocalsconf.idapp));
|
// console.log('pass', tools.getPwdByIdApp(mylocalsconf.idapp));
|
||||||
@@ -150,18 +154,18 @@ module.exports = {
|
|||||||
// },
|
// },
|
||||||
|
|
||||||
getlinkReg: function (idapp, idreg) {
|
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;
|
return strlinkreg;
|
||||||
},
|
},
|
||||||
getlinkRequestNewPassword: function (idapp, email, tokenforgot) {
|
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;
|
return strlinkreg;
|
||||||
},
|
},
|
||||||
sendEmail_Registration: async function (lang, emailto, user, idapp, idreg) {
|
sendEmail_Registration: async function (lang, emailto, user, idapp, idreg) {
|
||||||
|
|
||||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
locale: lang,
|
locale: lang,
|
||||||
@@ -183,13 +187,15 @@ module.exports = {
|
|||||||
|
|
||||||
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
|
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
|
||||||
|
|
||||||
|
tools.sendNotifToAdmin('Nuova Registrazione Utente: ' . name + ' ' + surname + ' (' + username + ')');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
|
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
|
||||||
|
|
||||||
mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
locale: lang,
|
locale: lang,
|
||||||
@@ -210,7 +216,7 @@ module.exports = {
|
|||||||
tools.mylog('sendEmail_Booking');
|
tools.mylog('sendEmail_Booking');
|
||||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||||
|
|
||||||
mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
locale: lang,
|
locale: lang,
|
||||||
@@ -262,7 +268,7 @@ module.exports = {
|
|||||||
|
|
||||||
tools.mylog('sendEmail_CancelBooking');
|
tools.mylog('sendEmail_CancelBooking');
|
||||||
|
|
||||||
mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
locale: lang,
|
locale: lang,
|
||||||
@@ -455,7 +461,7 @@ module.exports = {
|
|||||||
const baseurl = tools.getHostByIdApp(mylocalsconf.idapp);
|
const baseurl = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||||
const urlunsibscribe = baseurl + '/unsubscribe?em=' + mylocalsconf.hashemail + '&mc=' + mylocalsconf.dataemail.mailchimpactive + '&email=' + mylocalsconf.emailto;
|
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('{email}', mylocalsconf.emailto);
|
||||||
out = out.replace('{name}', mylocalsconf.name);
|
out = out.replace('{name}', mylocalsconf.name);
|
||||||
out = out.replace('{surname}', mylocalsconf.surname);
|
out = out.replace('{surname}', mylocalsconf.surname);
|
||||||
@@ -465,9 +471,9 @@ module.exports = {
|
|||||||
|
|
||||||
replacefields: function (mylocalsconf) {
|
replacefields: function (mylocalsconf) {
|
||||||
try {
|
try {
|
||||||
mylocalsconf.dataemail.disclaimer_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer);
|
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer) : '';
|
||||||
mylocalsconf.dataemail.disc_bottom_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom);
|
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom) : '';
|
||||||
mylocalsconf.dataemail.templ.testoheadermail_out = this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.templ.testoheadermail);
|
mylocalsconf.dataemail.templ.testoheadermail_out = !!mylocalsconf.dataemail.templ.testoheadermail ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.templ.testoheadermail) : '';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error replacefields: ' + e)
|
console.error('Error replacefields: ' + e)
|
||||||
}
|
}
|
||||||
@@ -515,12 +521,14 @@ module.exports = {
|
|||||||
smtpTransport = nodemailer.createTransport({
|
smtpTransport = nodemailer.createTransport({
|
||||||
host: mylocalsconf.dataemail.email_service,
|
host: mylocalsconf.dataemail.email_service,
|
||||||
port: mylocalsconf.dataemail.email_port,
|
port: mylocalsconf.dataemail.email_port,
|
||||||
|
secureConnection: false,
|
||||||
|
tls: {cipher:'SSLv3'},
|
||||||
auth: {
|
auth: {
|
||||||
user: mylocalsconf.dataemail.from,
|
user: mylocalsconf.dataemail.from,
|
||||||
pass: mylocalsconf.dataemail.pwd_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 = {
|
||||||
smtpTransport = nodemailer.createTransport({
|
smtpTransport = nodemailer.createTransport({
|
||||||
@@ -587,7 +595,7 @@ module.exports = {
|
|||||||
if (secpause < process.env.DELAY_SENDEMAIL)
|
if (secpause < process.env.DELAY_SENDEMAIL)
|
||||||
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) {
|
if (!activate) {
|
||||||
// Invio Newsletter Abortito!
|
// Invio Newsletter Abortito!
|
||||||
@@ -658,7 +666,7 @@ module.exports = {
|
|||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
activate = await Newstosent.isActivated(id_newstosent);
|
const activate = await Newstosent.isActivated(id_newstosent);
|
||||||
|
|
||||||
if (!activate) {
|
if (!activate) {
|
||||||
// Invio Newsletter Abortito!
|
// Invio Newsletter Abortito!
|
||||||
@@ -698,7 +706,7 @@ module.exports = {
|
|||||||
sendNewsletter: async function (rec, idapp) {
|
sendNewsletter: async function (rec, idapp) {
|
||||||
if (rec) {
|
if (rec) {
|
||||||
// Start the job
|
// Start the job
|
||||||
myjobnews = await Newstosent.findOne({ _id: rec._id });
|
let myjobnews = await Newstosent.findOne({ _id: rec._id });
|
||||||
if (!!myjobnews) {
|
if (!!myjobnews) {
|
||||||
myjobnews.starting_job = true;
|
myjobnews.starting_job = true;
|
||||||
myjobnews.datestartJob = new Date();
|
myjobnews.datestartJob = new Date();
|
||||||
@@ -748,8 +756,8 @@ module.exports = {
|
|||||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||||
|
|
||||||
|
|
||||||
mytitle = 'Prova msg'
|
let 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 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');
|
/*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) {
|
if (process.env.PROD !== 1) {
|
||||||
testmsgwebpush();
|
testmsgwebpush();
|
||||||
|
|
||||||
|
// tools.sendNotifToAdmin('Riparti', 'Riparti');
|
||||||
// sendemail.testemail('2', 'it');
|
// sendemail.testemail('2', 'it');
|
||||||
|
|
||||||
let miapass = '';
|
let miapass = '';
|
||||||
@@ -300,6 +302,7 @@ function testmsgwebpush() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Cron every X minutes
|
// Cron every X minutes
|
||||||
cron.schedule('*/2 * * * *', () => {
|
cron.schedule('*/2 * * * *', () => {
|
||||||
// console.log('Running Cron Job');
|
// console.log('Running Cron Job');
|
||||||
|
|||||||
@@ -633,7 +633,7 @@ module.exports = {
|
|||||||
allfieldProject: function () {
|
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',
|
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'
|
'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 () {
|
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) {
|
checkUserOk(userpassed, userauth, res) {
|
||||||
this.mylog('checkUserOk', userpassed, userauth);
|
this.mylog('checkUserOk', userpassed, userauth);
|
||||||
@@ -1379,6 +1400,16 @@ module.exports = {
|
|||||||
return dayOfWeek === 1
|
return dayOfWeek === 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isSundayDate(mydate) {
|
||||||
|
const dayOfWeek = mydate.getDay()
|
||||||
|
return dayOfWeek === 0
|
||||||
|
},
|
||||||
|
|
||||||
|
isMondayDate(mydate) {
|
||||||
|
const dayOfWeek = mydate.getDay()
|
||||||
|
return dayOfWeek === 1
|
||||||
|
},
|
||||||
|
|
||||||
getWeekDayByLang(date, lang) {
|
getWeekDayByLang(date, lang) {
|
||||||
return this.getWeekDayByLangByNumCar(date, lang, 3)
|
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) {
|
getstrDateLong(mydate, lang) {
|
||||||
if (mydate) {
|
if (mydate) {
|
||||||
// console.log('getstrDate', mytimestamp)
|
// console.log('getstrDate', mytimestamp)
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ module.exports = {
|
|||||||
SEND_TO_ALL: 1,
|
SEND_TO_ALL: 1,
|
||||||
SEND_TO_SOCI: 2,
|
SEND_TO_SOCI: 2,
|
||||||
SEND_TO_SOCIO_RESIDENTE: 3,
|
SEND_TO_SOCIO_RESIDENTE: 3,
|
||||||
SEND_TO_NON_SOCI: 10
|
SEND_TO_NON_SOCI: 10,
|
||||||
|
SEND_TO_PAOLO: 20
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeMsg_Actions: {
|
TypeMsg_Actions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user