- Send email when new subscriber to the newsletter
This commit is contained in:
3
emails/admin/added_to_newsletter/it/html.pug
Normal file
3
emails/admin/added_to_newsletter/it/html.pug
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
p #{name} #{surname} si è appena iscritto alla Newsletter di #{nomeapp} con email:
|
||||||
|
strong #{emailto}<br>
|
||||||
|
p <br>Saluti
|
||||||
1
emails/admin/added_to_newsletter/it/subject.pug
Normal file
1
emails/admin/added_to_newsletter/it/subject.pug
Normal file
@@ -0,0 +1 @@
|
|||||||
|
=`${name} ${surname} si è appena iscritto alla Newsletter con email: ${emailto} su ${nomeapp}`
|
||||||
@@ -19,16 +19,35 @@ const OperatorSchema = new Schema({
|
|||||||
username: {
|
username: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
|
surname: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: String,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
cell: {
|
cell: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
trim: true,
|
||||||
webpage: {
|
|
||||||
type: String,
|
|
||||||
},
|
},
|
||||||
img: {
|
img: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
skype: {
|
qualification: { // President, Vice-President, ecc...
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
disciplines: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
certifications: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
webpage: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
days_working: {
|
days_working: {
|
||||||
@@ -37,15 +56,26 @@ const OperatorSchema = new Schema({
|
|||||||
facebook: {
|
facebook: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
disciplines: {
|
info: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
intro: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
offers: {
|
offers: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
skype: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
OperatorSchema.statics.getFieldsForSearch = function () {
|
||||||
|
return ['name', 'surname', 'email', 'cell']
|
||||||
|
};
|
||||||
|
|
||||||
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
params.fieldsearch = this.getFieldsForSearch();
|
||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,6 +84,9 @@ OperatorSchema.statics.findAllIdApp = function (idapp) {
|
|||||||
|
|
||||||
const myfind = { idapp };
|
const myfind = { idapp };
|
||||||
|
|
||||||
|
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||||
|
|
||||||
|
|
||||||
return Operator.find(myfind, (err, arrrec) => {
|
return Operator.find(myfind, (err, arrrec) => {
|
||||||
return arrrec
|
return arrrec
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ var UserSchema = new mongoose.Schema({
|
|||||||
message: '{VALUE} is not a valid email'
|
message: '{VALUE} is not a valid email'
|
||||||
}*/
|
}*/
|
||||||
},
|
},
|
||||||
|
cell: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -359,7 +362,7 @@ UserSchema.statics.getUsersListByParams = function (params) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
UserSchema.statics.getFieldsForSearch = function () {
|
UserSchema.statics.getFieldsForSearch = function () {
|
||||||
return ['name', 'surname', 'email']
|
return ['name', 'surname', 'email', 'cell']
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.executeQueryTable = function (idapp, params) {
|
UserSchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ router.patch('/chval', authenticate, (req, res) => {
|
|||||||
const mytable = getTableByTableName(mydata.table);
|
const mytable = getTableByTableName(mydata.table);
|
||||||
const fieldsvalue = mydata.fieldsvalue;
|
const fieldsvalue = mydata.fieldsvalue;
|
||||||
|
|
||||||
tools.mylogshow('PATCH CHVAL: ', id);
|
tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
|
||||||
|
|
||||||
if (!User.isAdmin(req.user) && !User.isManager(req.user)) {
|
if (!User.isAdmin(req.user) && !User.isManager(req.user)) {
|
||||||
// If without permissions, exit
|
// If without permissions, exit
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const request = require('superagent');
|
const request = require('superagent');
|
||||||
|
|
||||||
|
const sendemail = require('../sendemail');
|
||||||
|
|
||||||
const newsletter = [
|
const newsletter = [
|
||||||
{
|
{
|
||||||
name: 'Paolo',
|
name: 'Paolo',
|
||||||
@@ -41,8 +43,17 @@ const newsletter = [
|
|||||||
router.post('/', (req, res) => {
|
router.post('/', (req, res) => {
|
||||||
|
|
||||||
idwebsite = req.body.idwebsite;
|
idwebsite = req.body.idwebsite;
|
||||||
|
idapp = req.body.idapp;
|
||||||
locale = req.body.locale;
|
locale = req.body.locale;
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
email: req.body.email,
|
||||||
|
name: req.body.firstName,
|
||||||
|
surname: req.body.lastName,
|
||||||
|
};
|
||||||
|
|
||||||
|
sendemail.sendEmail_Newsletter(locale, user, idapp);
|
||||||
|
|
||||||
request
|
request
|
||||||
.post('https://' + newsletter[idwebsite].mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + newsletter[idwebsite].listUniqueId + '/members/')
|
.post('https://' + newsletter[idwebsite].mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + newsletter[idwebsite].listUniqueId + '/members/')
|
||||||
.set('Content-Type', 'application/json;charset=utf-8')
|
.set('Content-Type', 'application/json;charset=utf-8')
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function checkifSendEmail() {
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sendEmail_base: function (template, user, to, mylocalsconf, replyTo) {
|
sendEmail_base: function (template, to, mylocalsconf, replyTo) {
|
||||||
|
|
||||||
console.log('mylocalsconf', mylocalsconf);
|
console.log('mylocalsconf', mylocalsconf);
|
||||||
|
|
||||||
@@ -135,13 +135,13 @@ module.exports = {
|
|||||||
emailto: emailto,
|
emailto: emailto,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.sendEmail_base('registration/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
this.sendEmail_base('registration/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send to the Admin an Email
|
// Send to the Admin an Email
|
||||||
this.sendEmail_base('admin/registration/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/registration/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/registration/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/registration/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sendEmail_RequestNewPassword: function (lang, emailto, idapp, tokenforgot) {
|
sendEmail_RequestNewPassword: function (lang, emailto, idapp, tokenforgot) {
|
||||||
@@ -154,7 +154,7 @@ module.exports = {
|
|||||||
emailto: emailto,
|
emailto: emailto,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.sendEmail_base('resetpwd/' + lang, user, emailto, mylocalsconf, '');
|
this.sendEmail_base('resetpwd/' + lang, emailto, mylocalsconf, '');
|
||||||
},
|
},
|
||||||
|
|
||||||
sendEmail_Booking: function (res, lang, emailto, user, idapp, recbooking) {
|
sendEmail_Booking: function (res, lang, emailto, user, idapp, recbooking) {
|
||||||
@@ -184,13 +184,13 @@ module.exports = {
|
|||||||
texthtml = 'makebooking';
|
texthtml = 'makebooking';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendEmail_base('booking/'+texthtml+'/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
this.sendEmail_base('booking/'+texthtml+'/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send Email also to the Admin
|
// Send Email also to the Admin
|
||||||
this.sendEmail_base('admin/'+texthtml+'/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/'+texthtml+'/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/'+texthtml+'/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -213,13 +213,13 @@ module.exports = {
|
|||||||
if (recbooking.numpeople > 1)
|
if (recbooking.numpeople > 1)
|
||||||
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti");
|
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + res.__("partecipanti");
|
||||||
|
|
||||||
this.sendEmail_base('booking/cancelbooking/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
this.sendEmail_base('booking/cancelbooking/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send Email also to the Admin
|
// Send Email also to the Admin
|
||||||
this.sendEmail_base('admin/cancelbooking/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/cancelbooking/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/cancelbooking/' + lang, user, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/cancelbooking/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -240,10 +240,29 @@ module.exports = {
|
|||||||
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.sendEmail_base('msg/sendmsg/' + lang, user, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
return this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send Email also to the Admin
|
// Send Email also to the Admin
|
||||||
// this.sendEmail_base('admin/sendmsg/' + lang, user, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
||||||
|
},
|
||||||
|
sendEmail_Newsletter: function (lang, user, idapp) {
|
||||||
|
|
||||||
|
console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
|
mylocalsconf = {
|
||||||
|
locale: lang,
|
||||||
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||||
|
name: user.name,
|
||||||
|
surname: user.surname,
|
||||||
|
emailto: user.email,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send to the Admin an Email
|
||||||
|
this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
|
this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
Permissions: {
|
Permissions: {
|
||||||
Normal: 0,
|
|
||||||
Admin: 1,
|
Admin: 1,
|
||||||
Manager: 2,
|
Manager: 2,
|
||||||
|
Teacher: 4,
|
||||||
},
|
},
|
||||||
|
|
||||||
MessageOptions: {
|
MessageOptions: {
|
||||||
@@ -12,7 +12,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fieldsUserToChange() {
|
fieldsUserToChange() {
|
||||||
return ['username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline']
|
return ['username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline']
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user