diff --git a/emails/admin/registration/esEs/html.pug b/emails/admin/registration/es/html.pug
similarity index 100%
rename from emails/admin/registration/esEs/html.pug
rename to emails/admin/registration/es/html.pug
diff --git a/emails/admin/registration/esEs/subject.pug b/emails/admin/registration/es/subject.pug
similarity index 100%
rename from emails/admin/registration/esEs/subject.pug
rename to emails/admin/registration/es/subject.pug
diff --git a/emails/registration/it/html.pug b/emails/registration/it/html.pug
index 7ce2789..d7b1cbe 100644
--- a/emails/registration/it/html.pug
+++ b/emails/registration/it/html.pug
@@ -2,8 +2,8 @@ p Benvenuto #{name} nel portale di #{nomeapp}!
p I tuoi dati di accesso da ricordare sono:
span Username:
strong #{username}
-span Password : (** non mostrata per privacy **)
-
+span hai dimenticato la Password? :
+ strong Trovala qui
span Email:
strong #{emailto}
p Per confermare la registrazione clicca sul bottone:
diff --git a/emails/registration/it/textold.pug b/emails/registration/it/textold.pug
deleted file mode 100644
index 7c751a2..0000000
--- a/emails/registration/it/textold.pug
+++ /dev/null
@@ -1,13 +0,0 @@
-Benvenuto #{name} nel portale di #{nomeapp}!
-I tuoi dati di accesso da ricordare sono:
- Username: #{username}
-
- hai dimenticato la Password?
- Trovala qui: #{forgetpwd}
-
- Email #{emailto}
-
-Per confermare la registrazione clicca su questo link:
-#{strlinkreg}
-
-Potrai cosi' accedere al sito digitando i tuoi dati di accesso.
diff --git a/emails/registration_ayni/enUs/html.pug b/emails/registration_ayni/enUs/html.pug
new file mode 100644
index 0000000..cf78ef0
--- /dev/null
+++ b/emails/registration_ayni/enUs/html.pug
@@ -0,0 +1,39 @@
+p Welcome #{name} to the portal #{nomeapp}!
+p Your access data to remember are:
+span Username:
+ strong #{username}
+span Forgot your Password? :
+ strong Find it here
+span Email:
+ strong #{emailto}
+p To confirm the registration click on the button:
+div.divbtn
+ button.btn.btn-lg Verify Registration
+
+
+p You can then access your personal area by clicking on LOGIN and filling in all the STEPS required by :
+ strong "Step by Step Guide" !
+
+
+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;
+
+ }
diff --git a/emails/registration_ayni/enUs/subject.pug b/emails/registration_ayni/enUs/subject.pug
new file mode 100644
index 0000000..b65f1d4
--- /dev/null
+++ b/emails/registration_ayni/enUs/subject.pug
@@ -0,0 +1 @@
+=`Confirm Registration to ${nomeapp}`
diff --git a/emails/registration_ayni/es/html.pug b/emails/registration_ayni/es/html.pug
new file mode 100644
index 0000000..093e9ed
--- /dev/null
+++ b/emails/registration_ayni/es/html.pug
@@ -0,0 +1,38 @@
+p ¡Bienvenido #{name} al portal #{nomeapp}!
+p Sus datos de acceso a recordar son:
+Nombre Usuario:
+ strong #{username}
+span ¿Olvidaste tu contraseña? :
+ strong Encuéntrelo aquí
+span Email:
+ strong #{emailto}
+p Para confirmar el registro haz clic en el botón:
+div.divbtn
+ button.btn.btn-lg Verificar registro
+
+p A continuación, puede acceder a su área personal haciendo clic en INICIAR SESIÓN y rellenando todos los PASOS requeridos por :
+ strong "Guía paso a paso"!
+
+
+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;
+
+ }
diff --git a/emails/registration_ayni/es/subject.pug b/emails/registration_ayni/es/subject.pug
new file mode 100644
index 0000000..0249b3d
--- /dev/null
+++ b/emails/registration_ayni/es/subject.pug
@@ -0,0 +1 @@
+=`Confirmar registro a ${nomeapp}`
diff --git a/emails/registration_ayni/it/html.pug b/emails/registration_ayni/it/html.pug
new file mode 100644
index 0000000..920f216
--- /dev/null
+++ b/emails/registration_ayni/it/html.pug
@@ -0,0 +1,38 @@
+p Benvenuto #{name} nel portale di #{nomeapp}!
+p I tuoi dati di accesso da ricordare sono:
+span Username:
+ strong #{username}
+span hai dimenticato la Password? :
+ strong Trovala qui
+span Email:
+ strong #{emailto}
+p Per confermare la registrazione clicca sul bottone:
+div.divbtn
+ button.btn.btn-lg Verifica Registrazione
+
+p Potrai cosi' accedere alla tua area personale cliccando su LOGIN e compilando tutti i PASSI richiesti dalla :
+ strong "Guida Passo Passo" !
+
+
+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;
+
+ }
diff --git a/emails/registration_ayni/it/subject.pug b/emails/registration_ayni/it/subject.pug
new file mode 100644
index 0000000..19c2e8a
--- /dev/null
+++ b/emails/registration_ayni/it/subject.pug
@@ -0,0 +1 @@
+=`Confermare la Registrazione a ${nomeapp}`
diff --git a/src/server/config/config.js b/src/server/config/config.js
index f826862..0715678 100644
--- a/src/server/config/config.js
+++ b/src/server/config/config.js
@@ -33,6 +33,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '2',
@@ -47,6 +48,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '3',
@@ -61,6 +63,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '4',
@@ -75,6 +78,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '6',
@@ -89,6 +93,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '7',
@@ -103,6 +108,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: 'b72b121f6fb69f7c58a269f5b5110e179430cd6fa940a168c2c10b255aa75fd1ebql9yXWoH1LwANdHD7Yvw==',
telegram_key:'1037577457:AAGQbdIuYoB838v61ewJ0Hearx9UPpTBhMI',
telegram_bot_name: 'notevoleaynibot',
+ pathreg_add:'_ayni',
},
{
idapp: '8',
@@ -117,6 +123,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
];
} else if (process.env.NODE_ENV === 'test') {
@@ -135,6 +142,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '2',
@@ -149,6 +157,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '3',
@@ -162,6 +171,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '4',
@@ -175,6 +185,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '6',
@@ -188,6 +199,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '7',
@@ -201,6 +213,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'1011893908:AAEThZB3fVPw8P5gTCFgTEsDmY21DdbV1Cw',
telegram_bot_name: 'testnotevoleaynibot',
+ pathreg_add:'_ayni',
},
{
idapp: '8',
@@ -215,6 +228,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
];
} else {
@@ -233,6 +247,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '2',
@@ -247,6 +262,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '3',
@@ -258,6 +274,7 @@ if (process.env.NODE_ENV === 'production') {
dir: '',
email_from: 'info.pianetalibero@gmail.com',
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
+ pathreg_add:'',
},
{
idapp: '4',
@@ -271,6 +288,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '6',
@@ -284,6 +302,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
{
idapp: '7',
@@ -297,6 +316,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_bot_name: 'paotestlocalebot',
telegram_key:'353996190:AAEcEbfrm_zTK6mBKf8ye9j-PXt958SDxew',
+ pathreg_add:'_ayni',
},
{
idapp: '8',
@@ -311,6 +331,7 @@ if (process.env.NODE_ENV === 'production') {
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_key:'',
telegram_bot_name: '',
+ pathreg_add:'',
},
];
diff --git a/src/server/models/newstosent.js b/src/server/models/newstosent.js
index 787ba1c..435ae16 100644
--- a/src/server/models/newstosent.js
+++ b/src/server/models/newstosent.js
@@ -123,7 +123,7 @@ NewstosentSchema.statics.findNewsletterPending_To_Send = function (idapp) {
starting_job: true,
finish_job: false,
processing_job: false,
- lastemailsent_Job: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 8) },
+ lastemailsent_Job: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 15) },
idapp
}).then((rec) => {
// console.log('findNewsletterPending_To_Send', rec);
diff --git a/src/server/models/user.js b/src/server/models/user.js
index 87e2e03..377e0b2 100644
--- a/src/server/models/user.js
+++ b/src/server/models/user.js
@@ -172,6 +172,9 @@ const UserSchema = new mongoose.Schema({
my_dream: {
type: String,
},
+ saw_and_accepted: {
+ type: Number,
+ },
saw_zoom_presentation: {
type: Boolean
},
@@ -324,10 +327,10 @@ UserSchema.statics.findByUsername = function (idapp, username) {
});
};
-UserSchema.statics.getUserShortDataByUsername = function (idapp, username) {
+UserSchema.statics.getUserShortDataByUsername = async function (idapp, username) {
const User = this;
- return User.findOne({
+ const myrec = await User.findOne({
'idapp': idapp,
'username': username,
}, {
@@ -338,6 +341,7 @@ UserSchema.statics.getUserShortDataByUsername = function (idapp, username) {
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
+ 'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.my_dream': 1,
'profile.paymenttypes': 1,
@@ -354,11 +358,18 @@ UserSchema.statics.getUserShortDataByUsername = function (idapp, username) {
return null;
}
});
+
+ if (myrec) {
+ myrec.numinvitati = await User.getnumInvitati(idapp, myrec.username);
+ myrec.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, myrec.username);
+ }
+
+ return myrec
};
-UserSchema.statics.getDownlineByUsername = function (idapp, username) {
+UserSchema.statics.getDownlineByUsername = async function (idapp, username) {
const User = this;
- return User.find({
+ const arrrec = await User.find({
'idapp': idapp,
'aportador_solidario': username,
}, {
@@ -370,6 +381,7 @@ UserSchema.statics.getDownlineByUsername = function (idapp, username) {
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
+ 'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.my_dream': 1,
'profile.paymenttypes': 1,
@@ -378,13 +390,18 @@ UserSchema.statics.getDownlineByUsername = function (idapp, username) {
date_reg: 1,
img: 1
}, (err, arrrec) => {
-
- for (const rec of arrrec) {
- rec.numinvitatiattivi = User.getnumInvitatiAttivi(idapp, rec.username);
- }
-
- return arrrec
+ return arrrec;
});
+
+ if (!!arrrec) {
+ for (const rec of arrrec) {
+ rec._doc.numinvitati = await User.getnumInvitati(idapp, rec.username);
+ rec._doc.numinvitatiattivi = await User.getnumInvitatiAttivi(idapp, rec.username);
+ }
+ }
+
+ return arrrec
+
};
@@ -396,6 +413,7 @@ UserSchema.statics.getnumInvitatiAttivi = function (idapp, username) {
aportador_solidario: username,
'profile.teleg_id': { $gt: 1 },
'profile.saw_zoom_presentation': true,
+ 'profile.saw_and_accepted': true,
});
};
@@ -602,7 +620,7 @@ UserSchema.statics.getusersManagers = async function (idapp) {
UserSchema.statics.getUsersTelegALL = async function (idapp) {
const User = this;
- return await User.find({ idapp, 'profile.teleg_id': { $gt: 0 } }, { 'profile.teleg_id': 1 })
+ return await User.find({ idapp, 'profile.teleg_id': { $gt: 0 } }, { 'profile.teleg_id': 1, perm: 1 })
.then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).catch((e) => {
@@ -729,7 +747,7 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
dashboard.myself = await User.getUserShortDataByUsername(idapp, username);
// Data of my Aportador
dashboard.aportador = await User.getUserShortDataByUsername(idapp, aportador_solidario);
- if (dashboard.aportador === undefined ) {
+ if (dashboard.aportador === undefined) {
dashboard.aportador = await ExtraList.getUserNotRegisteredByNameSurname(idapp, aportador_solidario_nome_completo);
}
@@ -827,6 +845,14 @@ UserSchema.statics.getUsersZoom = async function (idapp) {
return await User.count(myfind);
};
+UserSchema.statics.getSaw_and_Accepted = async function (idapp) {
+ const User = this;
+
+ const myfind = { idapp, 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED };
+
+ return await User.count(myfind);
+};
+
UserSchema.statics.getUsersDreams = async function (idapp) {
const User = this;
diff --git a/src/server/router/newsletter_router.js b/src/server/router/newsletter_router.js
index bb27e90..6d7b688 100644
--- a/src/server/router/newsletter_router.js
+++ b/src/server/router/newsletter_router.js
@@ -279,7 +279,7 @@ router.post('/setactivate', authenticate, async (req, res) => {
locale = req.body.locale;
const rec = {
- activate
+ activate,
};
return await Newstosent.findOneAndUpdate({ _id: id }, { $set: rec }, { new: false }).then((item) => {
diff --git a/src/server/router/notevole_router.js b/src/server/router/notevole_router.js
index 78a4266..143e56a 100644
--- a/src/server/router/notevole_router.js
+++ b/src/server/router/notevole_router.js
@@ -30,6 +30,7 @@ router.post('/load', async (req, res) => {
num_teleg_attivo: await User.getUsersTelegramAttivo(idapp),
num_teleg_pending: await User.getUsersTelegramPending(idapp),
num_part_zoom: await User.getUsersZoom(idapp),
+ num_part_accepted: await User.getSaw_and_Accepted(idapp),
num_users_dream: await User.getUsersDreams(idapp),
arr_nations: await User.findAllDistinctNationality(idapp),
reg_daily: await User.calcRegDaily(idapp),
diff --git a/src/server/sendemail.js b/src/server/sendemail.js
index df2fb6c..954c849 100644
--- a/src/server/sendemail.js
+++ b/src/server/sendemail.js
@@ -85,6 +85,8 @@ module.exports = {
const email = new Email(paramemail);
+ console.log(' *** Invia Email a ' + to);
+
return email
.send({
template: template,
@@ -148,7 +150,7 @@ module.exports = {
return strlinkreg;
},
getlinkRequestNewPassword: function (idapp, email, tokenforgot) {
- strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD + `?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
+ 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) {
@@ -164,12 +166,12 @@ module.exports = {
username: user.username,
name: user.name,
surname: user.surname,
- forgetpwd: "",
+ forgetpwd: tools.getHostByIdApp(idapp) + '/requestresetpwd',
emailto: emailto,
user,
};
- this.sendEmail_base('registration/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
+ this.sendEmail_base(tools.getpathregByIdApp(idapp, lang), emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
// Send to the Admin an Email
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
@@ -411,10 +413,13 @@ module.exports = {
},
replacefields: function (mylocalsconf) {
-
- 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);
+ 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);
+ } catch (e) {
+ console.error('Error replacefields: ' + e)
+ }
return mylocalsconf
},
@@ -445,7 +450,7 @@ module.exports = {
};
// console.log(mydata.templemail_id);
- mydata.templ = await TemplEmail.findOne({_id: mydata.templemail_id });
+ mydata.templ = await TemplEmail.findOne({ _id: mydata.templemail_id });
// console.log(mydata.templ);
return mydata
@@ -487,7 +492,10 @@ module.exports = {
sendEmail_Newsletter_Events: async function (lang, idapp, id_newstosent) {
- console.log('INIZIO - sendEmail_Newsletter_Events', tools.getNomeAppByIdApp(idapp));
+ const msginizio = 'INIZIO - sendEmail_Newsletter_Events: ' + tools.getNomeAppByIdApp(idapp);
+ console.log(msginizio);
+
+ telegrambot.sendMsgTelegramToTheManagers(idapp, msginizio);
//++Todo Extract List Email to send
const userstosend = await MailingList.findAllIdAppSubscribed(idapp);
@@ -507,76 +515,108 @@ module.exports = {
const mynewsrec = await Newstosent.findOne({ _id: id_newstosent });
- mynewsrec.numemail_tot = userstosend.length;
- mynewsrec.templemail_str = mylocalsconf.dataemail.templ.subject;
- mynewsrec.numemail_sent = await MailingList.getnumSent(idapp, id_newstosent);
+ try {
+ mynewsrec.numemail_tot = userstosend.length;
+ mynewsrec.templemail_str = mylocalsconf.dataemail.templ.subject;
+ mynewsrec.numemail_sent = await MailingList.getnumSent(idapp, id_newstosent);
- const smtpTransport = this.getTransport(mylocalsconf);
+ const smtpTransport = this.getTransport(mylocalsconf);
- // LOOP USERS EMAIL
- for (const user of userstosend) {
+ // LOOP USERS EMAIL
+ for (const user of userstosend) {
- const isok = await MailingList.isOk(idapp, user._id, id_newstosent);
- if (isok) {
- let secpause = await Settings.getValDbSettings(idapp, 'MSEC_PAUSE_SEND', process.env.DELAY_SENDEMAIL);
- if (secpause < process.env.DELAY_SENDEMAIL)
- secpause = process.env.DELAY_SENDEMAIL;
+ try {
- activate = await Newstosent.isActivated(id_newstosent);
+ const isok = await MailingList.isOk(idapp, user._id, id_newstosent);
+ if (isok) {
+ let secpause = await Settings.getValDbSettings(idapp, 'MSEC_PAUSE_SEND', process.env.DELAY_SENDEMAIL);
+ if (secpause < process.env.DELAY_SENDEMAIL)
+ secpause = process.env.DELAY_SENDEMAIL;
- if (!activate) {
- // Invio Newsletter Abortito!
- mynewsrec.error_job = 'Invio Newsletter abortito alle ore ' + new Date().toDateString() + new Date().toTimeString();
- await mynewsrec.save();
- await Newstosent.processingJob(id_newstosent, false);
- console.log('*** L\'Invio della Newsletter è stato fermato ! ');
- return false
+ activate = await Newstosent.isActivated(id_newstosent);
+
+ if (!activate) {
+ // Invio Newsletter Abortito!
+ mynewsrec.error_job = 'Invio Newsletter abortito alle ore ' + new Date().toDateString() + new Date().toTimeString();
+ telegrambot.sendMsgTelegramToTheManagers(idapp, mynewsrec.error_job);
+ await mynewsrec.save();
+ await Newstosent.processingJob(id_newstosent, false);
+ console.log('*** L\'Invio della Newsletter è stato fermato ! ');
+ return false
+ }
+
+ mylocalsconf.name = user.name;
+ mylocalsconf.surname = user.surname;
+ mylocalsconf.emailto = user.email;
+ mylocalsconf.hashemail = tools.getHash(user.email);
+
+ mylocalsconf = this.replacefields(mylocalsconf);
+
+
+ // If has already sent, don't send it again!
+ if (user.lastid_newstosent !== id_newstosent.toString()) {
+ // console.log('@@@@@ COMPARE DIVERSI: lastid', user.lastid_newstosent, 'idsent', id_newstosent.toString());
+
+ if (process.env.DEBUG)
+ await tools.snooze(5000);
+
+ // Send Email to the User
+ // console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
+ const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport);
+
+ if ((mynewsrec.numemail_sent % 50) === 0) {
+ const msgproc = 'In Corso ' + mynewsrec.numemail_sent + ' / ' + mynewsrec.numemail_tot + ' Email inviate...';
+ telegrambot.sendMsgTelegramToTheManagers(idapp, msgproc);
+ }
+
+ //Put the result in the database, to check if is sent or not.
+ const updateml = await MailingList.findOneAndUpdate({
+ idapp,
+ email: user.email
+ }, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
+
+
+ //Delay for send email...
+ await tools.snooze(secpause);
+
+ mynewsrec.lastemailsent_Job = new Date();
+ mynewsrec.numemail_sent = await MailingList.getnumSent(idapp, id_newstosent);
+
+ const recsaved = await mynewsrec.save();
+ } else {
+ console.log('*** COMPARE: UGUALI !!!!! lastid', user.lastid_newstosent, 'idsent', id_newstosent.toString());
+ }
+ }
+ } catch (e) {
+ const msgerr = 'Error LOOP sendEmail_Newsletter_Events: ' + e;
+ console.error(msgerr);
+ telegrambot.sendMsgTelegramToTheManagers(idapp, msgerr);
}
+ }
- mylocalsconf.name = user.name;
- mylocalsconf.surname = user.surname;
- mylocalsconf.emailto = user.email;
- mylocalsconf.hashemail = tools.getHash(user.email);
+ await Newstosent.endJob(id_newstosent);
+ await Newstosent.processingJob(id_newstosent, false);
+ let msgfine = 'FINE - sendEmail_Newsletter_Events [' + tools.getNomeAppByIdApp(idapp) + ']: ';
+ msgfine += mynewsrec.numemail_sent + ' Email inviate';
+ console.log(msgfine);
- mylocalsconf = this.replacefields(mylocalsconf);
+ telegrambot.sendMsgTelegramToTheManagers(idapp, msgfine);
+ } catch (e) {
- // If has already sent, don't send it again!
- if (user.lastid_newstosent !== id_newstosent.toString()) {
- console.log('@@@@@ COMPARE DIVERSI: lastid', user.lastid_newstosent, 'idsent', id_newstosent.toString());
+ activate = await Newstosent.isActivated(id_newstosent);
- if (process.env.DEBUG)
- await tools.snooze(5000);
-
- // Send Email to the User
- // console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
- const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport);
-
- //Put the result in the database, to check if is sent or not.
- const updateml = await MailingList.findOneAndUpdate({
- idapp,
- email: user.email
- }, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
-
-
- //Delay for send email...
- await tools.snooze(secpause);
-
- mynewsrec.lastemailsent_Job = new Date();
- mynewsrec.numemail_sent = await MailingList.getnumSent(idapp, id_newstosent);
-
- const recsaved = await mynewsrec.save();
- } else {
- console.log('*** COMPARE: UGUALI !!!!! lastid', user.lastid_newstosent, 'idsent', id_newstosent.toString());
- }
+ if (!activate) {
+ // Invio Newsletter Abortito!
+ mynewsrec.error_job = 'Invio Newsletter abortito alle ore ' + new Date().toDateString() + new Date().toTimeString();
+ telegrambot.sendMsgTelegramToTheManagers(idapp, mynewsrec.error_job);
+ await mynewsrec.save();
+ await Newstosent.processingJob(id_newstosent, false);
+ console.log('*** L\'Invio della Newsletter è stato fermato ! ');
+ return false
}
}
- await Newstosent.endJob(id_newstosent);
- await Newstosent.processingJob(id_newstosent, false);
- console.log('****', tools.getNomeAppByIdApp(idapp), mynewsrec.numemail_sent, 'Email inviate');
-
- console.log('FINE (esco da funz) - sendEmail_Newsletter_Events', tools.getNomeAppByIdApp(idapp));
},
@@ -597,11 +637,11 @@ module.exports = {
return Newstosent.findNewsletterPending_To_Send(idapp)
.then((rec) => { //
- this.sendNewsletter(rec)
+ this.sendNewsletter(rec, idapp)
});
},
- sendNewsletter: async function (rec) {
+ sendNewsletter: async function (rec, idapp) {
if (rec) {
// Start the job
myjobnews = await Newstosent.findOne({ _id: rec._id });
@@ -612,7 +652,7 @@ module.exports = {
myjobnews.save()
.then((ris) => {
- this.sendEmail_Newsletter_Events("it", '2', rec._id);
+ this.sendEmail_Newsletter_Events("it", idapp, rec._id);
})
.catch((e) => {
console.error(e);
diff --git a/src/server/server.js b/src/server/server.js
index 62c69f4..30454c7 100644
--- a/src/server/server.js
+++ b/src/server/server.js
@@ -42,6 +42,7 @@ require('./models/mypage');
require('./models/calzoom');
const mysql_func = require('./mysql/mysql_func');
+const { Newstosent } = require('./models/newstosent');
const index_router = require('./router/index_router');
const push_router = require('./router/push_router');
@@ -183,13 +184,13 @@ if (process.env.PROD !== 1) {
// testmsgwebpush();
// sendemail.testemail('2', 'it');
-/*
- let crypt = tools.cryptdata('');
- let decrypt = tools.decryptdata(crypt);
+ /*
+ let crypt = tools.cryptdata('');
+ let decrypt = tools.decryptdata(crypt);
- console.log('crypted:', crypt);
- console.log('decrypted:', decrypt);
-*/
+ console.log('crypted:', crypt);
+ console.log('decrypted:', decrypt);
+ */
mycron();
}
@@ -228,13 +229,13 @@ function startserv() {
// Check if is Empty (new Server Data)
-/*
- cfgserver.countDocuments(function (err, count) {
- if (!err && count === 0) {
- populateDBadmin();
- }
- });
-*/
+ /*
+ cfgserver.countDocuments(function (err, count) {
+ if (!err && count === 0) {
+ populateDBadmin();
+ }
+ });
+ */
}
@@ -273,6 +274,18 @@ cron.schedule('*/2 * * * *', () => {
mycron();
});
+async function resetProcessingJob() {
+
+ arrrec = await Newstosent.find({});
+
+ for (const rec of arrrec) {
+ rec.processing_job = false;
+ await Newstosent.findOneAndUpdate({ _id: rec.id }, { $set: rec }, { new: false }).then((item) => {
+
+ });
+ }
+}
+
//app.listen(port, () => {
// console.log(`Server started at port ${port}`);
//});
@@ -280,6 +293,14 @@ cron.schedule('*/2 * * * *', () => {
telegrambot.sendMsgTelegram('7', telegrambot.ADMIN_USER_SERVER, `Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
telegrambot.sendMsgTelegramByIdTelegram('7', telegrambot.ADMIN_IDTELEGRAM_SERVER, `Il Server ${process.env.DATABASE} è appena ripartito!`);
+telegrambot.sendMsgTelegramByIdTelegram('2', telegrambot.ADMIN_IDTELEGRAM_SERVER, `Il Server ${process.env.DATABASE} è appena ripartito!`);
+
+resetProcessingJob();
+
+
+//
+
+
// telegrambot.sendMsgTelegramToTheManagers('7', 'PROVAAA!');
// if (process.env.PROD !== 1) {
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index 3f89f56..3eb529e 100644
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -2,10 +2,14 @@ const tools = require('../tools/general');
const appTelegram = ['7'];
+const appTelegramFinti = ['2'];
+const appTelegramDest = ['7'];
+
const printf = require('util').format;
const { User } = require('../models/user');
const { CalZoom } = require('../models/calzoom');
+const shared_consts = require('../tools/shared_nodejs');
const emoji = require('node-emoji');
@@ -16,6 +20,9 @@ const Benvenuto = emoji.get('heartbeat') + emoji.get('heartbeat') + emoji.get('h
const emo = {
STARS: emoji.get('stars'),
FIRE: emoji.get('fire'),
+ TV: emoji.get('tv'),
+ NEWSPAPER: emoji.get('newspaper'),
+ PENCIL: emoji.get('pencil2'),
DREAM: emoji.get('beach_with_umbrella'),
EYES: emoji.get('eyes'),
DIZZY: emoji.get('dizzy'),
@@ -73,6 +80,7 @@ const Menu = {
ADMIN: emoji.get('information_desk_person') + ' Admin',
ALTRO: emoji.get('newspaper') + ' Altro',
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
+ MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
INDIETRO: emoji.get('back') + ' Indietro',
SI: emoji.get('thumbsup') + ' SI',
NO: emoji.get('thumbsdown') + ' NO',
@@ -85,8 +93,8 @@ const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.AS
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]];
const MenuYesNo = [[Menu.SI, Menu.NO]];
-const MenuAdmin = [[Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
-const MenuYes = [[Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
+const MenuAdmin = [[Menu.MSGSTAFF, Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
+const MenuYes = [[Menu.MSGSTAFF, Menu.INDIETRO], ['', '']];
const Status = {
NONE: 0,
@@ -175,9 +183,11 @@ module.exports = {
if (usersmanagers) {
for (const rec of usersmanagers) {
- this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' +emo.ADMIN + ': ' + text)
+ this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text)
+ await tools.snooze(300)
}
}
+ return true
},
@@ -185,9 +195,10 @@ module.exports = {
const usersall = await User.getUsersTelegALL(idapp);
if (usersall) {
- usersall.forEach((rec) => {
- this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, text)
- });
+ for (const rec of usersall) {
+ this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, text);
+ await tools.snooze(300)
+ }
}
},
@@ -277,6 +288,8 @@ class Telegram {
await this.menuAdmin(msg)
} else if (msg.text === Menu.MSGATUTTI) {
await this.menumsgAll(msg)
+ } else if (msg.text === Menu.MSGSTAFF) {
+ await this.menumsgStaff(msg)
} else if (msg.text === Menu.INDIETRO) {
await this.msgScegliMenu(msg);
} else {
@@ -332,6 +345,8 @@ class Telegram {
mystr += '\n' + this.getsymb(emo.ENVELOPE, rec.user.verified_email);
mystr += rec.user.verified_email ? tools.get__('EMAIL_VERIF', msg) : tools.get__('EMAIL_NON_VERIF', msg);
+ mystr += '\n' + '\n' + this.getsymb(emo.PENCIL, tools.isBitActive(rec.user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_READ_GUIDELINES)) + tools.get__('LINEE_GUIDA', msg);
+ mystr += '\n' + '\n' + this.getsymb(emo.TV, tools.isBitActive(rec.user.profile.saw_and_accepted, shared_consts.Accepted.CHECK_SEE_VIDEO_PRINCIPI)) + tools.get__('VIDEO_INTRO', msg);
mystr += '\n' + '\n' + this.getsymb(emo.EYES, rec.user.profile.saw_zoom_presentation) + tools.get__('ZOOM_PARTECIPATO', msg);
mystr += '\n' + '\n' + this.getsymb(emo.DREAM, this.isdreamset(rec.user)) + tools.get__('SCRITTO_SOGNO', msg);
@@ -366,7 +381,6 @@ class Telegram {
mystr += '\n' + printf(tools.get__('INFO_LAVAGNA_SITO', msg), tools.getHostByIdApp(this.idapp));
-
}
if (!!mystr)
await this.sendMsg(msg.chat.id, mystr);
@@ -436,16 +450,7 @@ class Telegram {
}
- await
- this
- .sendMsg(msg
-
- .chat
- .id
- ,
- mystr
- )
- ;
+ await this.sendMsg(msg.chat.id, mystr);
}
async menuAdmin(msg) {
@@ -459,6 +464,17 @@ class Telegram {
if (rec.user) {
const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:';
rec.msgall_status = StatusMSGALL.ASK;
+ rec.msgall_staff = false;
+ await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
+ }
+ }
+
+ async menumsgStaff(msg) {
+ const rec = this.getRecInMem(msg);
+ if (rec.user) {
+ const mystr = 'Scrivi qui un Messaggio da inviare allo STAFF:';
+ rec.msgall_status = StatusMSGALL.ASK;
+ rec.msgall_staff = true;
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
}
}
@@ -596,7 +612,7 @@ class Telegram {
}
}
- async sendMsgToAll(rec, msg, texttosend) {
+ async sendMsgToAll(rec, msg, texttosend, solostaff) {
if (texttosend.length < 3) {
} else {
const usersall = await
@@ -606,8 +622,15 @@ class Telegram {
if (usersall) {
for (const rec of usersall) {
- await this.sendMsg(rec.profile.teleg_id, texttosend);
- nummsgsent++;
+ let invia = true;
+ if (solostaff) {
+ invia = User.isManager(rec.perm)
+ }
+ if (invia) {
+ await this.sendMsg(rec.profile.teleg_id, texttosend);
+ nummsgsent++;
+ tools.snooze(300)
+ }
// ++Todo: SLEEP ??? sleep(0.03)
}
}
@@ -616,7 +639,6 @@ class Telegram {
this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT));
}
rec.start_write_msgall = false;
-
}
selectMenuHelp(msg) {
@@ -654,7 +676,7 @@ class Telegram {
if (msg.text === Menu.SI) {
// Take msg to send to ALL
await
- this.sendMsgToAll(rec, msg, rec.msgtosent)
+ this.sendMsgToAll(rec, msg, rec.msgtosent, rec.msgall_staff)
} else {
this.sendMsg(msg.chat.id, txt.MSG_OPERAZ_ANNULLATA);
}
@@ -664,7 +686,10 @@ class Telegram {
if (msg.text !== Menu.INDIETRO) {
rec.msgtosent = msg.text;
rec.msgall_status = StatusMSGALL.CONFIRM;
- const domanda = 'Confermi d\'Inviare questo messaggio a TUTTI ?\n' + rec.msgtosent;
+ let achi = "TUTTI";
+ if (rec.msgall_staff)
+ achi = "STAFF";
+ const domanda = 'Confermi d\'Inviare questo messaggio a ' + achi + ' ?\n' + rec.msgtosent;
this.ChiediSINO(msg, domanda);
} else {
rec.msgall_status = StatusMSGALL.NONE;
@@ -834,6 +859,14 @@ function getclTelegBytoken(token) {
}
function getclTelegByidapp(idapp) {
+ // ****************************
+ if (appTelegramFinti.includes(idapp)) {
+ const ind = appTelegramFinti.indexOf(idapp);
+ if (ind >= 0)
+ idapp = appTelegramDest[ind]; // Invia
+ }
+
+
const rec = arrTelegram.find((rec) => rec.idapp === idapp);
if (!!rec)
return rec.cl;
diff --git a/src/server/tools/general.js b/src/server/tools/general.js
index df6ffc5..538f884 100644
--- a/src/server/tools/general.js
+++ b/src/server/tools/general.js
@@ -12,7 +12,7 @@ const Url = require('url-parse');
const { ObjectID } = require('mongodb');
-const shared_consts = require('../tools/shared_nodejs');
+const shared_consts = require('./shared_nodejs');
const mongoose = require('mongoose');
const Subscription = mongoose.model('subscribers');
@@ -56,6 +56,8 @@ textlang = {
'TELEGRAM_NOT_CONNECTED': "Telegram non associato al tuo account!",
'NESSUN_INVITATO': 'Non hai invitato nessuno',
'ZOOM_PARTECIPATO': 'Partecipazione ad almeno 1 Conferenza (Zoom)',
+ 'LINEE_GUIDA': 'Accettato le Linee Guida',
+ 'VIDEO_INTRO': 'Visto il Video di AYNI',
'SCRITTO_SOGNO': 'Hai scritto il tuo Sogno',
'INVITATI': 'persone registrate che hai invitato',
'NONREG': 'Invitati non Registrati',
@@ -77,6 +79,8 @@ textlang = {
'TELEGRAM_NOT_CONNECTED': "Telegram non associato al tuo account!",
'NESSUN_INVITATO': 'Non hai invitato nessuno',
'ZOOM_PARTECIPATO': 'Partecipazione ad almeno 1 Conferenza (Zoom)',
+ 'LINEE_GUIDA': 'Accettato le Linee Guida',
+ 'VIDEO_INTRO': 'Visto il Video di AYNI',
'SCRITTO_SOGNO': 'Hai scritto il tuo Sogno',
'INVITATI': 'persone registrate che hai invitato',
'NONREG': 'Invitati non Registrati',
@@ -94,6 +98,8 @@ textlang = {
'TELEGRAM_NOT_CONNECTED': "Telegram non associato al tuo account!",
'NESSUN_INVITATO': 'Non hai invitato nessuno',
'ZOOM_PARTECIPATO': 'Partecipazione ad almeno 1 Conferenza (Zoom)',
+ 'LINEE_GUIDA': 'Accettato le Linee Guida',
+ 'VIDEO_INTRO': 'Visto il Video di AYNI',
'SCRITTO_SOGNO': 'Hai scritto il tuo Sogno',
'INVITATI': 'persone registrate che hai invitato',
'NONREG': 'Invitati non Registrati',
@@ -488,6 +494,14 @@ module.exports = {
return '';
},
+ getpathregByIdApp: function (idapp, lang) {
+ const myapp = MYAPPS.find((item) => item.idapp === idapp);
+ if (myapp)
+ return 'registration' + myapp.pathreg_add + '/' + lang;
+ else
+ return '';
+ },
+
isManagAndAdminDifferent(idapp) {
const manag = this.getManagerEmailByIdApp(idapp);
return (manag !== this.getAdminEmailByIdApp(idapp)) && (manag !== '');
diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js
index 707fa96..4545252 100644
--- a/src/server/tools/shared_nodejs.js
+++ b/src/server/tools/shared_nodejs.js
@@ -1,4 +1,11 @@
module.exports = {
+ Accepted: {
+ CHECK_READ_GUIDELINES: 1,
+ CHECK_SEE_VIDEO_PRINCIPI: 2,
+ },
+
+ ALL_SAW_AND_ACCEPTED: 3,
+ // ---------------------
FILTER_EXTRALIST_NOT_REGISTERED: 1,
FILTER_EXTRALIST_NOT_CONTACTED: 2,
@@ -23,7 +30,7 @@ module.exports = {
},
fieldsUserToChange() {
- return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'date_temp_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order']
+ return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'date_temp_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'numinvitati', 'numinvitatiattivi']
}
};