- Add Button Whatsapp Chat

- Fixed 'Ask Info' and 'Book' if the email arrived...
- Added "Settings" table: URL_FACEBOOK, TELEGRAM_SUPPORT, URL_INSTAGRAM, WHATSAPP_CELL, INT_CODE, MAIN_EMAIL, CONTACTS_EMAIL_CELL, CALL_WORKING_DAYS, EVENTS_CAL, MSG_REPLY_AFTER_BOOKING.
-
This commit is contained in:
Paolo Arena
2019-11-05 23:53:39 +01:00
parent 9205468065
commit a54839e128
12 changed files with 107 additions and 47 deletions

View File

@@ -2,6 +2,7 @@ p Ciao #{name},
p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event}
span #{participants}
p Messaggio: #{msgbooking}
p #{msgreply_after_booking}
p Cordiali Saluti
p Supporto #{nomeapp}

View File

@@ -2,10 +2,6 @@ p Ciao #{name},
p #{usernameorig} ti ha inviato questo messaggio dalla pagina
span (#{infoevent}):
p #{message}
p
p Per rispondere al messaggio clicca qui:
div.divbtn <a href=#{strlinkreply} target="_blank">
button.btn.btn-lg Rispondi</a>
p Cordiali Saluti
p Supporto #{nomeapp}
@@ -15,20 +11,3 @@ style(type="text/css").
padding: 0;
margin: 0;
}
.divbtn {
display: flex;
align-items: center;
justify-content: center;
}
.btn-lg {
padding: 5px;
margin: 5px;
font-size: 26px;
cursor: pointer;
color: white;
background: #027be3 !important;
border-radius: 28px;
}

View File

@@ -0,0 +1,34 @@
p Ciao #{name},
p #{usernameorig} ti ha inviato questo messaggio dalla pagina
span (#{infoevent}):
p #{message}
p
p Per rispondere al messaggio clicca qui:
div.divbtn <a href=#{strlinkreply} target="_blank">
button.btn.btn-lg Rispondi</a>
p Cordiali Saluti
p Supporto #{nomeapp}
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}
.divbtn {
display: flex;
align-items: center;
justify-content: center;
}
.btn-lg {
padding: 5px;
margin: 5px;
font-size: 26px;
cursor: pointer;
color: white;
background: #027be3 !important;
border-radius: 28px;
}

View File

@@ -0,0 +1 @@
=`${usernameorig} tu ha inviato un nuovo messaggio`

View File

@@ -37,6 +37,26 @@ SettingsSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
SettingsSchema.statics.getValDbSettings = function (idapp, key) {
return Settings.findOne({ idapp, key })
.then((myrec) => {
if (myrec) {
if (myrec.type === this.FieldType.date)
return myrec.value_date;
if (myrec.type === this.FieldType.number)
return myrec.value_num;
else
return myrec.value_str;
} else {
return ''
}
}).catch((err) => {
return null;
});
};
SettingsSchema.statics.findAllIdApp = function (idapp) {
const Settings = this;

View File

@@ -34,7 +34,7 @@ router.post('/', authenticate, (req, res) => {
tools.mylog('crea Booking');
const booking = new Booking(myrec);
const check = tools.checkUserOk(booking.userId, req.user._id);
const check = tools.checkUserOk(booking.userId, req.user._id, res);
if (check.exit) return check.ret;
// console.log('fieldtochange', fieldtochange);
@@ -81,10 +81,12 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {
return res.status(404).send();
}
if (notify === '1')
if (notify === '1') {
recbooking.booked = false;
sendNotif(res, idapp, req.user, recbooking);
}
tools.mylog('DELETED ', recbooking.descr, recbooking._id);
tools.mylog('DELETED ', recbooking._id);
res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recbooking._id });

View File

@@ -25,7 +25,7 @@ router.post('/', authenticate, (req, res) => {
tools.mylog('crea MyEvent');
const myevent = new MyEvent(myrec);
const check = tools.checkUserOk(myevent.userId, req.user._id);
const check = tools.checkUserOk(myevent.userId, req.user._id, res);
if (check.exit) return check.ret;
// Modify:

View File

@@ -31,7 +31,7 @@ router.post('/', authenticate, (req, res) => {
return res.status(400).send({ code: server_constants.RIS_CODE_LOGIN_ERR_GENERIC });
}
const check = tools.checkUserOk(project.userId, req.user._id);
const check = tools.checkUserOk(project.userId, req.user._id, res);
if (check.exit) return check.ret;
tools.mylog('PROJECT POST :', project.descr, project._id);

View File

@@ -42,7 +42,7 @@ router.post('/', authenticate, (req, res) => {
tools.mylog('crea SendMsg');
const myrecmsg = new SendMsg(body);
const check = tools.checkUserOk(myrecmsg.origin.username, req.user.username);
const check = tools.checkUserOk(myrecmsg.origin.username, req.user.username, res);
if (check.exit) return check.ret;
// console.log('fieldtochange', fieldtochange);

View File

@@ -6,6 +6,7 @@ const Email = require('email-templates');
var i18n = require("i18n");
const { Settings } = require('./models/settings');
const previewEmail = require('preview-email');
const nodemailer = require("nodemailer");
@@ -174,24 +175,29 @@ module.exports = {
event: recbooking.infoevent,
};
if (recbooking.numpeople > 1)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti");
return Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING').then((ris => {
mylocalsconf.msgreply_after_booking = ris;
let texthtml = '';
if (recbooking.modified) {
texthtml = 'modifybooking';
}else {
texthtml = 'makebooking';
}
if (recbooking.numpeople > 1)
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti");
this.sendEmail_base('booking/'+texthtml+'/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
let texthtml = '';
if (recbooking.modified) {
texthtml = 'modifybooking';
}else {
texthtml = 'makebooking';
}
// Send Email also to the Admin
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
this.sendEmail_base('booking/'+texthtml+'/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
// Send Email also to the Admin
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
}
}));
},
@@ -240,7 +246,13 @@ module.exports = {
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
};
return this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
let replyto = '';
if (mylocalsconf.infoevent !== '')
replyto = user.email;
else
replyto = tools.getreplyToEmailByIdApp(idapp);
return this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, replyto);
// Send Email also to the Admin
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);

View File

@@ -33,6 +33,17 @@ module.exports = {
TYPE_PROJECT: 1,
TYPE_TODO: 2,
FieldType: {
boolean: 1,
date: 2,
string: 4,
binary: 8,
html: 16,
select: 32,
number: 64,
typeinrec: 128,
},
MAX_PHASES: 5,
FIRST_PROJ: '__PROJECTS',
EXECUTE_CALCPROJ: true,
@@ -280,11 +291,11 @@ module.exports = {
return sortedList;
},
checkUserOk(userpassed, userauth) {
checkUserOk(userpassed, userauth, res) {
this.mylog('checkUserOk', userpassed, userauth);
if (String(userpassed) !== String(userauth)) {
// I'm trying to write something not mine!
this.mylog('userId = ', userpassed.userId, 'req.user._id', userauth);
this.mylog('userId = ', userpassed, 'req.user._id', userauth);
return { exit: true, ret: res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER }) }
} else {
return { exit: false, ret: false }
@@ -388,7 +399,7 @@ module.exports = {
]
}
if (idapp > 0) {
query.push( { $match: { idapp } } );
query.push({ $match: { idapp } });
}
// console.log('QUERYMATCH', query[0].$match.or);
@@ -457,6 +468,6 @@ module.exports = {
SetBit(myval, bit) {
myval = myval & bit;
return myval
}
},
};

View File

@@ -12,7 +12,7 @@ module.exports = {
},
fieldsUserToChange() {
return ['username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline', 'profile']
return ['_id', 'username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline', 'profile']
}
};