corretto bug GruppoMacro la lista veniva salvata ma anche aggiornata in memoria con solo gli ID... in questo caso TABLES_NON_AGGIORNARE_IN_MEMORIA_PERCHE_DIVERSA_STRUTTURA gli dice che alcune tabelle non devono essere aggiornate in memoria.
This commit is contained in:
@@ -29,7 +29,7 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
TOKEN_LIFE=1m
|
||||
TOKEN_LIFE=10m
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
DATABASE=test_FreePlanet
|
||||
DATABASE=test_PiuCheBuono
|
||||
UDB=paofreeplanet
|
||||
PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
appTelegram_DEVELOP=["13"]
|
||||
appTelegram_TEST=["1","17"]
|
||||
appTelegram=["1","17"]
|
||||
appTelegram_DEVELOP=["17"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=0
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
@@ -29,7 +29,7 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
TOKEN_LIFE=30m
|
||||
TOKEN_LIFE=2h
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
@@ -38,4 +38,9 @@ FTPSERVER_PWD=ftpmypwd@1A_
|
||||
AUTH_NEW_SITES=123123123
|
||||
SCRIPTS_DIR=admin_scripts
|
||||
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
||||
MIAB_HOST=box.lamiaposta.org
|
||||
MIAB_ADMIN_EMAIL=admin@lamiaposta.org
|
||||
MIAB_ADMIN_PASSWORD=passpao1pabox@1A
|
||||
DS_API_KEY="sk-222e3addb3d8455d8b0516d93906eec7"
|
||||
SERVER_A_URL="http://51.77.156.69:3000"
|
||||
API_KEY_MSSQL="m68yADSr123MIVIDA@154$DSAGVOK"
|
||||
87
src/models/listainvitiemail.js
Executable file
87
src/models/listainvitiemail.js
Executable file
@@ -0,0 +1,87 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const ListaInvitiEmailSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
userIdInvite: {
|
||||
type: String,
|
||||
},
|
||||
date_Invited: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
clicked: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
registered: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
userIdRegistered: {
|
||||
type: String,
|
||||
},
|
||||
token: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var ListaInvitiEmail = module.exports = mongoose.model('ListaInvitiEmail', ListaInvitiEmailSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [{ field: 'email', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getLastRec = async function (idapp) {
|
||||
const lastrec = await ListaInvitiEmail.find({ idapp }).sort({ dateofreg: -1 }).limit(1);
|
||||
if (!!lastrec) {
|
||||
return lastrec[0];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.findByEmail = function (idapp, email) {
|
||||
|
||||
return ListaInvitiEmail.findOne({
|
||||
'idapp': idapp,
|
||||
'email': email,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await tools.findAllQueryIdApp(this, myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes()
|
||||
.then(() => { })
|
||||
.catch((err) => { throw err; });
|
||||
|
||||
@@ -533,6 +533,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return await myPromise
|
||||
.then(async (doupdate) => {
|
||||
if (false) {
|
||||
|
||||
@@ -38,6 +38,42 @@ router.post('/invia-email', authenticate, async (req, res) => {
|
||||
|
||||
const dati = { messaggioPersonalizzato, emailAmico, usernameInvitante };
|
||||
|
||||
const userInvitante = await User.findOne({ idapp, username: usernameInvitante }, { username: 1 });
|
||||
|
||||
const invitoesiste = await ListaInvitiEmail.findOne({ idapp, email });
|
||||
if (invitoesiste) {
|
||||
const dateInvito = new Date(invitoesiste.date_Invited);
|
||||
const dateNow = new Date();
|
||||
const diffTime = Math.abs(dateNow - dateInvito);
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24 * 7));
|
||||
|
||||
if (diffDays > 7) {
|
||||
// Posso reinviare l'invito
|
||||
await ListaInvitiEmail.deleteOne({ _id: invitoesiste._id });
|
||||
invitoesiste = null;
|
||||
} else {
|
||||
return res.status(200).json({
|
||||
success: false,
|
||||
message: `L'invito a questa email è stato già inviato il ${dateInvito.toDateString()}`,
|
||||
emailInviata: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const token = crypto.createHash('sha256').update(JSON.stringify(dati)).digest('hex');
|
||||
|
||||
dati.token = token;
|
||||
|
||||
// aggiungi la email alla lista inviti
|
||||
const listainviti = new ListaInvitiEmail({
|
||||
idapp,
|
||||
email: emailAmico,
|
||||
userIdInvite: userInvitante.username,
|
||||
token,
|
||||
});
|
||||
|
||||
await listainviti.save();
|
||||
|
||||
const ris = await sendemail.sendEmail_InvitaAmico('it', emailAmico, null, idapp, dati);
|
||||
|
||||
if (ris) {
|
||||
|
||||
@@ -494,8 +494,8 @@ module.exports = {
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `/?idapp=${idapp}&idlink=${idreg}`;
|
||||
return strlinkreg;
|
||||
},
|
||||
getlinkInvitoReg: function (idapp, usernameInvitante) {
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINK_INVITO_A_REG + `/?idapp=${idapp}&inv=${usernameInvitante}`;
|
||||
getlinkInvitoReg: function (idapp, dati) {
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINK_INVITO_A_REG + `/?idapp=${idapp}&tok=${dati.token}`;
|
||||
return strlinkreg;
|
||||
},
|
||||
sendEmail_Registration: async function (lang, emailto, user, idapp, idreg) {
|
||||
@@ -556,7 +556,7 @@ module.exports = {
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
strlinksito: tools.getHostByIdApp(idapp),
|
||||
//strlinkreg: this.getlinkReg(idapp, idreg),
|
||||
linkRegistrazione: this.getlinkInvitoReg(idapp, dati.usernameInvitante),
|
||||
linkRegistrazione: this.getlinkInvitoReg(idapp, dati),
|
||||
emailto: emailto,
|
||||
usernameInvitante: dati.usernameInvitante,
|
||||
messaggioPersonalizzato: dati.messaggioPersonalizzato,
|
||||
|
||||
Reference in New Issue
Block a user