This commit is contained in:
Paolo Arena
2021-02-18 12:19:35 +01:00
parent 88ae9af12c
commit 14a3292da2
22 changed files with 233 additions and 122 deletions

View File

@@ -1,6 +1,8 @@
p Ciao,
p Ti avvisiamo che #{name} #{surname} ha appena cancellato la prenotazione per l'evento #{event}:
span #{participants}
span #{participantsLunch}
span #{participantsDinner}
p Cordiali Saluti
p Supporto #{nomeapp}

View File

@@ -1,6 +1,8 @@
p Ciao,
p Ti confermiamo che #{name} #{surname} ha appena inviato una richiesta di prenotazione per l'evento #{event}
span #{participants}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p Messaggio: #{msgbooking}
p Cordiali Saluti

View File

@@ -1,6 +1,8 @@
p Ciao,
p Ti confermiamo che #{name} #{surname} ha appena Modificato la sua prenotazione per l'evento #{event}
span #{participants}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p Messaggio: #{msgbooking}
p Cordiali Saluti

View File

@@ -1,6 +1,8 @@
p Ciao #{name},
p Ti confermiamo che la prenotazione per l'evento "#{event}" è stata cancellata.
span #{participants}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p Cordiali Saluti
p Supporto #{nomeapp}

View File

@@ -1,6 +1,8 @@
p Ciao #{name},
p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event}
span #{participants}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p Messaggio: #{msgbooking}
p #{msgreply_after_booking}

View File

@@ -1,6 +1,8 @@
p Ciao #{name},
p Ti confermiamo che hai modificato la prenotazione per l'evento #{event}
span #{participants}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}
p Messaggio: #{msgbooking}
p Cordiali Saluti

View File

@@ -158,7 +158,7 @@ if (process.env.NODE_ENV === 'production') {
portapp: '0',
dir: '/var/www/comunitanuovomondo.app',
email_from: 'cnmrimini@gmail.com',
email_pwd: 'cdd333bf42a655243e9f4e97d39d7a3a9360211ecba1ce052d5b7e22630acbbfTgI3kQya6Y0NB+qnspFg9w==',
email_pwd: 'b11837c0cfbf77b84cdbb44ecf9ee4f6b91f12599b76568e6b2b35c2bdb91291baHEPn6Q9wTgMOW29IQB3w==',
telegram_key:'1202788747:AAErwzIsD7k-3Yj5AX6ci3p7ELMuyASq4vA',
telegram_bot_name: 'comunitanuovomondo_bot',
pathreg_add:'_cnm',

View File

@@ -26,6 +26,12 @@ const bookingSchema = new Schema({
numpeople: {
type: Number,
},
numpeopleLunch: {
type: Number,
},
numpeopleDinner: {
type: Number,
},
infoevent: {
type: String,
},

View File

@@ -1208,11 +1208,12 @@ ListaIngressoSchema.statics.getnumInvitati = async function (idapp, username) {
ListaIngressoSchema.statics.Esegui_CronTab = async function (idapp, mydata) {
const ListaIngresso = this;
console.log('Lancia CronTab: [IDAPP=' + idapp + ']');
// console.log('Lancia CronTab: [IDAPP=' + idapp + ']');
let num = 0;
try {
/*
if (!await Graduatoria.isUpdating()) {
await Graduatoria.setGradUpdating(idapp, true);
@@ -1222,14 +1223,14 @@ ListaIngressoSchema.statics.Esegui_CronTab = async function (idapp, mydata) {
await Graduatoria.setWorking(idapp, false);
num = await Nave.generaNave(idapp, mydata, false);
}
}*/
} catch (e) {
console.error('ERRORE CronTab: [IDAPP=' + idapp + ']', e.message);
} finally {
await Graduatoria.setGradUpdating(idapp, false);
await Graduatoria.setWorking(idapp, false);
// await Graduatoria.setGradUpdating(idapp, false);
// await Graduatoria.setWorking(idapp, false);
console.log('FINE CronTab: [IDAPP=' + idapp + ']');
}

View File

@@ -88,6 +88,27 @@ const MyEventSchema = new Schema({
canceled: {
type: Boolean,
},
lunchAvailable: {
type: Boolean,
},
dinnerAvailable: {
type: Boolean,
},
lunchType: {
type: Number,
},
dinnerType: {
type: Number,
},
lunchPrice: {
type: Number,
},
dinnerPrice: {
type: Number,
},
internal: {
type: Boolean,
},
deleted: {
type: Boolean,
},
@@ -99,13 +120,33 @@ const MyEventSchema = new Schema({
},
});
MyEventSchema.statics.findAllIdApp = function (idapp) {
MyEventSchema.statics.findAllIdApp = function (socioresidente, idapp) {
const Event = this;
const query = [
{ $match: { idapp } },
{ $sort: { dateTimeStart: 1 } }
];
let query = []
if (socioresidente) {
query = [
{
$match: {
idapp,
}
}
]
} else {
query = [
{
$match: {
idapp,
$or: [
{ $or: [{ internal: { $exists: false } }, { internal: { $exists: true, $eq: false } }] },
],
}
}
]
}
query.push({ $sort: { dateTimeStart: 1 } })
return Event
.aggregate(query)

View File

@@ -188,7 +188,7 @@ ProjectSchema.statics.findAllProjByUserId = async function (userId, idapp) {
{
$and: [
{ idapp }, {
$or: [{ privacyread: server_constants.Privacy.all }, { userId: userId }],
$or: [{ privacyread: { $ne: server_constants.Privacy.onlyme } }, { userId: userId }],
}],
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
}
@@ -336,7 +336,7 @@ ProjectSchema.statics.enabletoModify = async function (userId, idProj) {
return Project.findOne({
'_id': idProj,
$or: [{
privacywrite: server_constants.Privacy.all,
privacywrite: { $ne: server_constants.Privacy.onlyme },
userId: userId
}]
}).then(ris => {

View File

@@ -59,7 +59,7 @@ SettingsSchema.statics.getValDbSettings = function (idapp, key, def) {
if (!!myrec) {
if (myrec.type === tools.FieldType.date)
return myrec.value_date;
else if (myrec.type === tools.FieldType.number)
else if ((myrec.type === tools.FieldType.number) || (myrec.type === tools.FieldType.hours))
return myrec.value_num;
else if (myrec.type === tools.FieldType.boolean)
return myrec.value_bool;

View File

@@ -62,6 +62,7 @@ var TodoSchema = new mongoose.Schema({
},
phase: {
type: Number,
default: 1
},
assignedToUsers: [
{ type: String }
@@ -127,7 +128,7 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
function getQueryFilterTodo(userId) {
let myobj = [
{ userId: userId },
// { userId: userId },
{
$or:
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]

View File

@@ -28,7 +28,7 @@ router.post('/', authenticate, (req, res) => {
// tools.mylog('INIZIO - booking');
// tools.mylog('req.body', req.body);
const myrec = _.pick(req.body, tools.allfieldBooking());
const id = myrec._id;
const id = myrec.id_bookedevent;
const fieldtochange = _.pick(myrec, tools.allfieldBookingChange());
tools.mylog('crea Booking');
@@ -45,13 +45,13 @@ router.post('/', authenticate, (req, res) => {
// console.log('trovato', trovato);
if (trovato) {
return Booking.findOneAndUpdate({ id_bookedevent: id }, { $set: fieldtochange }, {
new: true,
new: false,
upsert: true
}).then((recbooking) => {
// tools.mylog('booking:', booking);
// tools.mylog('already exist');
sendNotif(res, myrec.idapp, req.user, recbooking);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recbooking._id });
sendNotif(res, myrec.idapp, req.user, myrec);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: id_bookedevent });
});
} else {
// save to database a new record
@@ -62,8 +62,8 @@ router.post('/', authenticate, (req, res) => {
Booking.findById(idobj)
.then((recbooking) => {
sendNotif(res, myrec.idapp, req.user, recbooking);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recbooking._id });
sendNotif(res, myrec.idapp, req.user, writeresult);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: writeresult._id });
});
});
}

View File

@@ -70,7 +70,7 @@ const actions = require('./api/actions');
const shared_consts = require('../tools/shared_nodejs');
UserCost = {
const UserCost = {
FIELDS_REQUISITI: ['verified_email',
'profile.teleg_id',
'profile.saw_and_accepted',
@@ -191,7 +191,7 @@ router.post(process.env.LINK_UPDATE_PWD, (req, res) => {
function getTableByTableName(tablename) {
mytable = '';
let mytable = '';
if (tablename === 'users')
mytable = User;
else if (tablename === 'tessitura')
@@ -299,16 +299,17 @@ router.post('/settable', authenticate, (req, res) => {
return res.send(rec);
}).catch((e) => {
console.log(e.message);
if (e.code === 11000) {
const id = mytablerec._id;
delete mytablerec._doc['_id'];
return mytablestrutt.findByIdAndUpdate(id, { $set: mytablerec._doc }).then(async (rec) => {
return res.send(rec);
}).catch((e) => {
tools.mylog('error: ', e.message);
return res.status(400).send(e);
}).catch((err) => {
tools.mylog('error: ', err.message);
return res.status(400).send(err);
})
} else {
console.log(e.message);
}
});
@@ -374,7 +375,7 @@ router.patch('/chval', authenticate, async (req, res) => {
// tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
// If I change my record...
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTraduttrici(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) {
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTraduttrici(req.user.perm) && !User.isTutor(req.user.perm)) && (req.user._id.toString() !== id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) {
// If without permissions, exit
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
@@ -457,7 +458,7 @@ router.patch('/chval', authenticate, async (req, res) => {
const risunset = await mytable.findByIdAndUpdate(id, { $unset: unset });
if (!!risunset) {
if ('date_made_gift' in unset) {
addtext = strflotta + ` E' stato annullato l'invio del dono di ${myuser.name} ${myuser.surname} (${myuser.username}) da parte di ${req.user.name} ${req.user.surname} - [Posiz: ${fieldsvalue.riga}.${fieldsvalue.col}]`;
let addtext = strflotta + ` E' stato annullato l'invio del dono di ${myuser.name} ${myuser.surname} (${myuser.username}) da parte di ${req.user.name} ${req.user.surname} - [Posiz: ${fieldsvalue.riga}.${fieldsvalue.col}]`;
telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, false);
tools.writeFlottaLog(idapp, addtext, flotta.riga, flotta.col_prima);
@@ -484,7 +485,7 @@ router.patch('/chval', authenticate, async (req, res) => {
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, mydata.notifBot.txt);
if (!!addmsg)
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, addmsg);
addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt;
let addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt;
telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, true);
if (!!flotta)
@@ -513,7 +514,7 @@ router.patch('/chval', authenticate, async (req, res) => {
}*/
if ('aportador_solidario' in fieldsvalue) {
ind_order_ingr = mydata.ind_order_ingr;
let ind_order_ingr = mydata.ind_order_ingr;
// SERVE SE CI METTO LE MINUSCOLE/MAIUSCOLE SBAGLIATE in invitante_username!
const myuserfound = await User.findByUsername(idapp, fieldsvalue.aportador_solidario, false);
if (!!myuserfound) {
@@ -530,7 +531,7 @@ router.patch('/chval', authenticate, async (req, res) => {
invitante_username: aportador
};
//Aggiorna record !
const ris = await ListaIngresso.findByIdAndUpdate(myfirstrec._id.toString(), { $set: fieldsv2 });
await ListaIngresso.findByIdAndUpdate(myfirstrec._id.toString(), { $set: fieldsv2 });
}
}
}
@@ -630,15 +631,15 @@ router.patch('/chval', authenticate, async (req, res) => {
router.patch('/askfunz', authenticate, async (req, res) => {
// const idapp = req.body.idapp;
const id = req.body.data.id;
const ind_order = req.body.data.ind_order;
const username = req.body.data.username;
// const ind_order = req.body.data.ind_order;
// const username = req.body.data.username;
const idapp = req.body.idapp;
const mydata = req.body.data;
let entra = false;
if (!entra) {
// If I change my record...
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id)) {
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && (req.user._id.toString() !== id)) {
// If without permissions, exit
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
@@ -677,12 +678,12 @@ router.patch('/askfunz', authenticate, async (req, res) => {
router.patch('/callfunz', authenticate, async (req, res) => {
// const idapp = req.body.idapp;
const id = req.body.data.id;
const ind_order = req.body.data.ind_order;
// const ind_order = req.body.data.ind_order;
const username = req.body.data.username;
const idapp = req.body.idapp;
const mydata = req.body.data;
const telegrambot = require('../telegram/telegrambot');
// const telegrambot = require('../telegram/telegrambot');
try {
let entra = false;
@@ -692,7 +693,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
}
if (!entra) {
// If I change my record...
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id)) {
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && (req.user._id.toString() !== id)) {
// If without permissions, exit
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
@@ -700,29 +701,28 @@ router.patch('/callfunz', authenticate, async (req, res) => {
let myuser = await User.findOne({ idapp, username });
let rimosso = 0;
let fieldsvalue = {}
if (mydata.myfunc === shared_consts.CallFunz.SOSTITUISCI) { // SOSTITUISCI
username_da_sostituire = mydata.data.username_da_sostituire;
let username_da_sostituire = mydata.data.username_da_sostituire;
let myuservecchio = await User.findOne({ idapp, username: username_da_sostituire });
mianavedasost = await Nave.findOne({ idapp, riga: mydata.data.riga, col: mydata.data.col });
let mianavedasost = await Nave.findOne({ idapp, riga: mydata.data.riga, col: mydata.data.col });
if (!!mianavedasost) {
// Sostituisci l'Utente
myusernuovo = await User.getUserShortDataByUsername(idapp, mydata.data.username);
let myusernuovo = await User.getUserShortDataByUsername(idapp, mydata.data.username);
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, mydata.data.riga, mydata.data.col, 0);
if (!!myusernuovo) {
if (myusernuovo) {
if (!mydata.data.AddImbarco && !!mianavedasost && mianavedasost.ind_order > 0) {
if (!mydata.data.AddImbarco && mianavedasost.ind_order > 0) {
// Controlla prima se è in una Nave Temporanea, allora lo elimina dall'ultima Nave Temporanea
miaarrnavi = await Nave.getArrPosizioniByUsername(idapp, username);
let miaarrnavi = await Nave.getArrPosizioniByUsername(idapp, username);
if (miaarrnavi) {
miaarrnavi = miaarrnavi.reverse(); // parto dall'ultima
for (const mianave of miaarrnavi) {
@@ -734,7 +734,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
let ris = await Nave.findByIdAndUpdate(mianave._id, { $set: fieldsvalue });
if (!!ris) {
rimosso++;
// rimosso++;
break; // Rimuovilo solo 1 !
}
}
@@ -742,8 +742,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
}
}
if (!!myusernuovo) {
if (!!mianavedasost && mianavedasost.ind_order >= 0) {
if (mianavedasost.ind_order >= 0) {
// ELIMINO LA LISTAINGRESSO CHE STO SOSTITUENDO (SOLO SE NON VIENE USATA DA ALTRA NAVE!)
let eliminatoingr = await ListaIngresso.eliminaListaIngresso(idapp, mianavedasost.ind_order, req, mianavedasost.num_tess);
@@ -755,7 +754,6 @@ router.patch('/callfunz', authenticate, async (req, res) => {
});
}
}
}
if (!!myuservecchio) {
if (mydata.data.notifBot) {
@@ -771,7 +769,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
if (!!rismsg) {
let messaggio = rismsg.body;
mytitle = rismsg.title;
// let mytitle = rismsg.title;
if (!!messaggio) {
await telegrambot.sendMsgTelegram(idapp, myusernuovo.username, messaggio);
}
@@ -781,7 +779,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
// Se ha gia delle altre navi, non cancellarlo!
if (!await Nave.checkIfMadeGift(idapp, myuservecchio.username)) {
if (mydata.data.deleteUser && !!mianavedasost && mianavedasost.ind_order > 0) {
if (mydata.data.deleteUser && mianavedasost.ind_order > 0) {
// Metti Deleted allo User
fieldsvalue = {
deleted: true,
@@ -846,7 +844,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myusernuovo.lang, myusernuovo, false);
let messaggio = rismsg.body;
mytitle = rismsg.title;
let mytitle = rismsg.title;
// const myplacca = await Nave.getNavePos(idapp, navepersistente.riga, navepersistente.col);
// messaggio += tools.ACAPO + myplacca;
@@ -896,7 +894,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
} else if (mydata.myfunc === shared_consts.CallFunz.AGGIUNGI_NUOVO_IMBARCO) {
// Ottieni il prossimo Numero di Tessitura
//let num_tess = await Nave.getNextNumTess(idapp, ind_order);
const num_tess = 1;
// const num_tess = 1;
/*
let listaingr = await ListaIngresso.find({ idapp, ind_order }).sort({ num_tess: 1 });
@@ -909,9 +907,9 @@ router.patch('/callfunz', authenticate, async (req, res) => {
// metti l'invitante inizialmente a Te stesso !
const invitante_username = req.body.data.invitante_username;
ris = await ListaIngresso.addUserInListaIngresso(idapp, username, invitante_username, myuser.lang, true, true);
await ListaIngresso.addUserInListaIngresso(idapp, username, invitante_username, myuser.lang, true, true);
arrimbarchi = await ListaIngresso.findAllByUsername(idapp, username);
let arrimbarchi = await ListaIngresso.findAllByUsername(idapp, username);
return res.send({ code: server_constants.RIS_CODE_OK, arrimbarchi });
} else if (mydata.myfunc === shared_consts.CallFunz.CANCELLA_IMBARCO) {
@@ -919,7 +917,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
const myrec = await ListaIngresso.getIngrEUserByFilter(idapp, { idapp, _id: ObjectID(mydata.data.id) });
if (!!myrec) {
const myingr = await ListaIngresso.find({ _id: mydata.data.id });
await ListaIngresso.find({ _id: mydata.data.id });
const risdel = await ListaIngresso.eliminaListaIngresso(idapp, mydata.ind_order, req, mydata.data.num_tess);
@@ -931,7 +929,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
} else if (mydata.myfunc === shared_consts.CallFunz.ZOOM_GIA_PARTECIPATO) {
if (!!myuser.username) {
FormDaMostrare = telegrambot.getFormDaMostrare(idapp, mydata.myfunc, myuser);
let FormDaMostrare = telegrambot.getFormDaMostrare(idapp, mydata.myfunc, myuser);
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuser.name} ${myuser.surname} (${myuser.username}) ha detto di aver già visto lo Zoom di Benvenuto`, false, FormDaMostrare);
@@ -980,9 +978,9 @@ router.get('/copyfromapptoapp/:idapporig/:idappdest', async (req, res) => {
router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
const id = req.params.id;
const idapp = req.user.idapp;
// const idapp = req.user.idapp;
const tablename = req.params.table;
let notifBot = false;
// let notifBot = false;
// const idapp = req.body.idapp;
console.log('id', id, 'table', tablename);
@@ -998,8 +996,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
let cancellato = false;
notifBot = tools.NotifyIfDelRecord(tablename);
let myrec = null;
// tools.NotifyIfDelRecord(tablename);
if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) {
if (tablename === 'users') {
@@ -1009,8 +1006,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
date_deleted: new Date(),
};
const rec = await mytable.findByIdAndUpdate(id, { $set: fieldsvalue });
myrec = rec;
await mytable.findByIdAndUpdate(id, { $set: fieldsvalue });
cancellato = true;
}
@@ -1024,7 +1020,6 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
// res.status(404).send();
return false;
}
myrec = rec;
cancellato = true;
@@ -1106,12 +1101,15 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
const userId = req.params.userId;
const idapp = req.params.idapp;
const sall = req.params.sall;
// var category = req.params.category;
// tools.mylog('loadsite : ', req.params);
let bookedevent = [];
let msgs = [];
// let msgs = [];
const socioresidente = req.user.profile.socioresidente;
if (userId !== '0') {
// LOGGED WITH USERID
@@ -1119,7 +1117,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
}
// Extract all the todos of the userId only
const eventlist = MyEvent.findAllIdApp(idapp);
const eventlist = MyEvent.findAllIdApp(socioresidente, idapp);
const operators = Operator.findAllIdApp(idapp);
const wheres = Where.findAllIdApp(idapp);
const contribtype = Contribtype.findAllIdApp(idapp);
@@ -1216,7 +1214,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
// const sall = '0';
// msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
let last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
let usersList = null;
@@ -1225,7 +1223,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
if (User.isAdmin(req.user.perm)) {
// Send UsersList
// usersList = User.getUsersList(req.user.idapp)
usersList = null;
// usersList = null;
}
}
@@ -1247,8 +1245,8 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
});
router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {
const dir = req.params.dir;
const idapp = req.user.idapp;
// const dir = req.params.dir;
// const idapp = req.user.idapp;
/*
const form = new formidable.IncomingForm();
@@ -1335,7 +1333,7 @@ router.post('/upload/:dir', authenticate, (req, res) => {
// Create Dir if doesn't exist:
tools.mkdirpath(mydir);
newname = mydir + '/' + file.name;
let newname = mydir + '/' + file.name;
console.log('move from ', file.path, 'to :', newname);
@@ -1381,7 +1379,7 @@ router.delete('/delfile', authenticate, (req, res) => {
try {
console.log('Delete file ' + relativefile);
// ++ Move in the folder application !
fullpathfile = tools.getdirByIdApp(idapp) + '/' + relativefile;
let fullpathfile = tools.getdirByIdApp(idapp) + '/' + relativefile;
tools.delete(fullpathfile, (err) => {
if (err) console.log('err', err);

View File

@@ -34,7 +34,7 @@ router.post('/', authenticate, (req, res) => {
// console.log('trovato', trovato);
if (trovato) {
return myevent.findOneAndUpdate({ id }, { $set: fieldtochange }, {
new: true,
new: false,
upsert: true
}).then((recmyevent) => {
// tools.mylog('myevent:', myevent);

View File

@@ -47,7 +47,7 @@ router.post('/', authenticate, (req, res) => {
.then(record => {
// tools.mylog('REC SAVED :', record.descr);
res.send({ record });
res.send({ record: record._doc });
/*
tools.sendNotificationToUser(project.userId, 'Project: ' + record.descr, record.descr, '/project/' + project.category, '', 'project', [])
@@ -96,8 +96,7 @@ router.patch('/:id', authenticate, (req, res) => {
return res.status(404).send();
}
if (project.userId !== String(req.user._id)) {
if (project.userId !== String(req.user._id) && project.privacywrite === server_constants.Privacy.onlyme) {
// I'm trying to write something not mine!
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
}
@@ -143,8 +142,6 @@ router.get('/calc/:id/:actualphase', authenticate, (req, res) => {
var id = req.params.id;
var actualphase = parseInt(req.params.actualphase);
let rec = {};
return Todo.calculateTreeTodo(actualphase, '', id, false, id, false)
.then((rec) => {
return res.send({ rec });
@@ -191,6 +188,7 @@ router.get('/:userId', authenticate, (req, res) => {
});
/*
// USATO SOLO LE PRIME VOLTE! O A RICHIESTA!
async function calcProjects(userId, obj) {
@@ -215,6 +213,7 @@ async function calcProjects(userId, obj) {
}
}
*/
// USATO SOLO LE PRIME VOLTE! O A RICHIESTA!
async function calcSingleProject(userId, myproj) {
@@ -226,7 +225,7 @@ async function calcSingleProject(userId, myproj) {
router.delete('/:id', authenticate, (req, res) => {
var id = req.params.id;
let hide = true;
const hide = true;
if (!ObjectID.isValid(id)) {
return res.status(404).send();

View File

@@ -81,6 +81,14 @@ router.patch('/:id', authenticate, (req, res) => {
return res.status(404).send();
}
Todo.findById(id)
.then((todorec) => {
if (todorec) {
// Esiste, pertanto gli tolgo l'UserId generato in precedenza
delete body["userId"];
}
Todo.findByIdAndUpdate(id, { $set: body }, { new: true })
.then((todo) => {
if (!todo) {
@@ -93,7 +101,7 @@ router.patch('/:id', authenticate, (req, res) => {
.then(objdatacalc => {
// tools.mylogshow(' TODO TO MODIFY: ', todo.descr, todo.expiring_at);
if (todo.userId !== String(req.user._id)) {
if (todo.userId !== String(req.user._id) && project.privacywrite === server_constants.Privacy.onlyme) {
// I'm trying to write something not mine!
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
}
@@ -109,6 +117,7 @@ router.patch('/:id', authenticate, (req, res) => {
tools.mylogserr('Error patch TODO: ', e);
res.status(400).send();
})
})
});

View File

@@ -219,6 +219,8 @@ module.exports = {
surname: user.surname,
emailto: emailto,
participants: '',
participantsLunch: '',
participantsDinner: '',
msgbooking: tools.convertTexttoHtml(recbooking.msgbooking),
eventtextplain: tools.removeSpecialCharForEmail(recbooking.infoevent),
event: recbooking.infoevent,
@@ -227,9 +229,15 @@ module.exports = {
return Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING').then((ris => {
mylocalsconf.msgreply_after_booking = ris;
if (recbooking.numpeople > 1)
if (recbooking.numpeople > 0)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
if (recbooking.numpeopleLunch > 0)
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
if (recbooking.numpeopleDinner > 0)
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
let texthtml = '';
if (recbooking.modified) {
texthtml = 'modifybooking';
@@ -264,12 +272,20 @@ module.exports = {
emailto: emailto,
event: recbooking.infoevent,
participants: '',
participantsLunch: '',
participantsDinner: '',
eventtextplain: tools.removeSpecialCharForEmail(recbooking.infoevent),
};
if (recbooking.numpeople > 1)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
if (recbooking.numpeopleLunch > 1)
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
if (recbooking.numpeopleDinner > 1)
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
this.sendEmail_base('booking/cancelbooking/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send Email also to the Admin

View File

@@ -281,7 +281,7 @@ function testmsgwebpush() {
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
User.find({ username: 'paoloar77' }).then((arrusers) => {
User.find({ username: 'paoloarcnm' }).then((arrusers) => {
if (arrusers !== null) {
for (const user of arrusers) {
tools.sendNotificationToUser(user._id, 'Server', 'Il Server è Ripartito', '/', '', 'server', [])

View File

@@ -2,6 +2,9 @@ const os = require("os");
const fs = require('fs');
const path = require('path');
require('../config/config');
require('../models/subscribers');
@@ -52,7 +55,9 @@ textlang = {
"L'Email è già stata Verificata": "L'Email è già stata Verificata",
"Nuova Registrazione": "Nuova Registrazione",
"Effettuata una Nuova Registrazione": "Effettuata una Nuova Registrazione",
"partecipanti": "partecipanti",
"partecipanti": "partecipanti all'Evento",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "<strong><a href=\"%s\">👉 Per entrare nel Sito AYNI</a></strong>\n\n" +
"👉 <strong><a href=\"https://ayni.gifteconomy.app/requestresetpwd\">Hai dimenticato la password?</a></strong>\n\n" +
"👉 Entra nel Canale d'Informazione per Importanti Avvisi!\n<strong><a href=\"%s\">Canale AYNI-BIBLIO</a></strong>\n\n" +
@@ -124,6 +129,8 @@ textlang = {
"Nuova Registrazione": "Nova Registracija",
"Effettuata una Nuova Registrazione": "Izpelji novo Registracijo",
"partecipanti": "Udeleženci",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "Za vstop na spletno stran:\n%s\n\n" +
"Si pozabil geslo za vstop na stran?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" +
"Klepet AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\n" +
@@ -193,6 +200,8 @@ textlang = {
"Nuova Registrazione": "Nuevo Registro",
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
"partecipanti": "participantes",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "Para entrar en el sitio de AYNI:\n%s\n\n" +
"¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" +
"Chat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\n" +
@@ -257,6 +266,8 @@ textlang = {
},
enUs: {
"partecipanti": "participants",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "To enter the AYNI Site:\n%s\n\nForgot your password to access the site?\n" +
"https://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\n" +
"Chat AYNI - EMPOWER: Enter ⛩ into our chat community:\n%s\n\n" +
@@ -324,6 +335,8 @@ textlang = {
"Nuova Registrazione": "Nouvelle inscription",
"Effettuata una Nuova Registrazione": "Un nouvel enregistrement a été effectué",
"partecipanti": "participants",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "Pour entrer sur le site AYNI:\n%s\n\n" +
"Vous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" +
"Chat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\n" +
@@ -392,6 +405,8 @@ textlang = {
"Nuova Registrazione": "Novo Registo",
"Effettuata una Nuova Registrazione": "Foi efectuado um novo registo",
"partecipanti": "participantes",
"partecipanti a Pranzo": "partecipanti a Pranzo",
"partecipanti a Cena": "partecipanti a Cena",
'TESTO_ASSISTENZA': "Para entrar no site do AYNI:\n%s\n\n" +
"Esqueceu sua senha para acessar o site?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" +
"Chat AYNI BOT (isto):\nhttps://t.me/notevoleaynibot\n\n" +
@@ -522,6 +537,12 @@ module.exports = {
password: 512,
listimages: 1024,
exact: 2048,
image: 3000,
nationality: 4096,
intcode: 5000,
multioption: 6000,
onlydate: 7000,
hours: 8000
},
MAX_PHASES: 5,
@@ -616,11 +637,11 @@ module.exports = {
},
allfieldBooking: function () {
return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
return ['idapp', 'userId', 'id_bookedevent', 'numpeople', 'numpeopleLunch', 'numpeopleDinner', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
},
allfieldBookingChange: function () {
return ['numpeople', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
return ['numpeople', 'numpeopleLunch', 'numpeopleDinner', 'msgbooking', 'modified', 'infoevent', 'datebooked', 'booked']
},
allfieldProjectWithId: function () {
@@ -978,8 +999,8 @@ module.exports = {
data[rec.field] = params.filter.trim();
} else if (rec.type === this.FieldType.string) {
data[rec.field] = myregexp;
} else if (rec.type === this.FieldType.number) {
data[rec.field] = parseInt(params.filter.trim());
} else if ((rec.type === this.FieldType.number) || (rec.type === this.FieldType.hours)) {
data[rec.field] = parseFloat(params.filter.trim());
}
myfilters.push(data);
});
@@ -1610,8 +1631,11 @@ module.exports = {
try {
fs.mkdirSync(dirPath, { recursive: true });
} catch (e) {
mkdirpath(path.dirname(dirPath));
mkdirpath(dirPath);
if (dirPath !== path.dirname(dirPath)) {
const myname = path.dirname(dirPath);
this.mkdirpath(myname);
// this.mkdirpath(dirPath);
}
}
}
},
@@ -1671,6 +1695,9 @@ module.exports = {
if (table === 'sharewithus') {
return true;
}
if (table === 'hours') {
return true;
}
if (table === 'users') {
if ('aportador_solidario' in fieldsvalue) {
return true;

View File

@@ -94,7 +94,8 @@ module.exports = Object.freeze({
all: 'all',
friends: 'friends',
mygroup: 'mygroup',
onlyme: 'onlyme'
onlyme: 'onlyme',
inherited: 'inherited'
},
TypeProj: {