- corretto sendemail password... l'ho cambiata. e ho messo dei controlli
This commit is contained in:
BIN
emails/.DS_Store
vendored
BIN
emails/.DS_Store
vendored
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -430,7 +430,7 @@ class GenPdf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onlinePdfFromIdCatalog(options) {
|
async onlinePdfFromIdCatalog(options) {
|
||||||
const risout = await GenPdf.onlinePdf(options);
|
const risout = await this.onlinePdf(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async generatePdfFromIdCatalog(options) {
|
async generatePdfFromIdCatalog(options) {
|
||||||
|
|||||||
@@ -64,9 +64,13 @@ const GenPdf = require('../modules/GenPdf');
|
|||||||
|
|
||||||
const genPdf = new GenPdf();
|
const genPdf = new GenPdf();
|
||||||
|
|
||||||
(async () => {
|
let genPdfLaunched = false;
|
||||||
await genPdf.launch();
|
function launchGenPdfIfNeeded() {
|
||||||
})();
|
if (!genPdfLaunched) {
|
||||||
|
genPdfLaunched = true;
|
||||||
|
genPdf.launch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function updateProductInfo(recproductInfoAttuale, product, idapp, mycatstr) {
|
async function updateProductInfo(recproductInfoAttuale, product, idapp, mycatstr) {
|
||||||
if (!recproductInfoAttuale || !mycatstr) return recproductInfoAttuale;
|
if (!recproductInfoAttuale || !mycatstr) return recproductInfoAttuale;
|
||||||
@@ -618,6 +622,8 @@ router.post('/online-pdf', authenticate, async (req, res) => {
|
|||||||
console.log('/online-pdf');
|
console.log('/online-pdf');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
launchGenPdfIfNeeded(); // Ensure GenPdf is launched before proceeding
|
||||||
|
|
||||||
const risout = await GenPdf.onlinePdf(req.body);
|
const risout = await GenPdf.onlinePdf(req.body);
|
||||||
|
|
||||||
return res.status(200).send(risout);
|
return res.status(200).send(risout);
|
||||||
@@ -2641,6 +2647,7 @@ router.post('/generate-pdf', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
launchGenPdfIfNeeded(); // Ensure GenPdf is launched before proceeding
|
||||||
const pdfPath = await genPdf.generatePdfFromUrl(url, filename);
|
const pdfPath = await genPdf.generatePdfFromUrl(url, filename);
|
||||||
res.download(pdfPath);
|
res.download(pdfPath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ router.post('/track-pageview', authenticate_noerror, async (req, res) => {
|
|||||||
|
|
||||||
await pageView.save();
|
await pageView.save();
|
||||||
|
|
||||||
res.status(200).json({ message: 'Visita registrata' });
|
res.status(200).json({ message: '' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Errore nel salvataggio della visita:', error);
|
console.error('Errore nel salvataggio della visita:', error);
|
||||||
res.status(500).json({ error: 'Impossibile registrare la visita' });
|
res.status(500).json({ error: 'Impossibile registrare la visita' });
|
||||||
|
|||||||
@@ -106,6 +106,15 @@ module.exports = {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// se non è presente la password, non inviare l'email e manda messaggio di errore !
|
||||||
|
|
||||||
|
if (!paramemail.transport.options.auth.pass) {
|
||||||
|
let email = paramemail.transport.options.auth.user;
|
||||||
|
|
||||||
|
console.error('❌ Password mancante ! Impossibile inviare le email. user=', email);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// console.table(paramemail.transport);
|
// console.table(paramemail.transport);
|
||||||
|
|
||||||
// console.log('2 . paramemail.transport', paramemail.transport);
|
// console.log('2 . paramemail.transport', paramemail.transport);
|
||||||
@@ -125,9 +134,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
locals: mylocalsconf,
|
locals: mylocalsconf,
|
||||||
}).then((ris) => {
|
}).then((ris) => {
|
||||||
|
if (ris?.response && ris.response.includes('Ok')) {
|
||||||
|
console.log('✅ Email INVIATA')
|
||||||
|
}
|
||||||
// console.log('ris EMAIL', ris);
|
// console.log('ris EMAIL', ris);
|
||||||
return !!ris;
|
return !!ris;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
console.log('❌ Email NON INVIATA!');
|
||||||
console.error('sendEmail_base Error: ', err);
|
console.error('sendEmail_base Error: ', err);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -754,7 +767,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTransport: (mylocalsconf) => {
|
getTransport: (mylocalsconf) => {
|
||||||
console.log('getTransport');
|
// console.log('getTransport');
|
||||||
|
|
||||||
// Create Transport
|
// Create Transport
|
||||||
let smtpTransport = null;
|
let smtpTransport = null;
|
||||||
|
|||||||
@@ -267,13 +267,13 @@ connectToDatabase(connectionUrl, options)
|
|||||||
|
|
||||||
await tools.getApps();
|
await tools.getApps();
|
||||||
|
|
||||||
|
let miapass = '';
|
||||||
|
|
||||||
if (process.env.PROD !== 1) {
|
if (process.env.PROD !== 1) {
|
||||||
testmsgwebpush();
|
testmsgwebpush();
|
||||||
|
|
||||||
// tools.sendNotifToAdmin('Riparti', 'Riparti');
|
// tools.sendNotifToAdmin('Riparti', 'Riparti');
|
||||||
|
|
||||||
let miapass = '';
|
|
||||||
|
|
||||||
if (miapass !== '') {
|
if (miapass !== '') {
|
||||||
let crypt = tools.cryptdata(miapass);
|
let crypt = tools.cryptdata(miapass);
|
||||||
let decrypt = tools.decryptdata(crypt);
|
let decrypt = tools.decryptdata(crypt);
|
||||||
@@ -285,8 +285,24 @@ connectToDatabase(connectionUrl, options)
|
|||||||
mycron();
|
mycron();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
miapass = 'PROVA123@';
|
||||||
|
let crypt = tools.cryptdata(miapass);
|
||||||
|
let decrypt = tools.decryptdata(crypt);
|
||||||
|
|
||||||
telegrambot = require('./telegram/telegrambot');
|
telegrambot = require('./telegram/telegrambot');
|
||||||
|
|
||||||
|
if (decrypt === miapass) {
|
||||||
|
console.log('✅ Decrypt OK');
|
||||||
|
// OK FUNZIONA
|
||||||
|
} else {
|
||||||
|
let msgerr = '❌ ERRORE! la decrittazione non funziona! ';
|
||||||
|
console.error(msgerr);
|
||||||
|
await telegrambot.sendMsgTelegramToTheAdminAllSites(
|
||||||
|
msgerr,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await inizia();
|
await inizia();
|
||||||
|
|
||||||
await resetProcessingJob();
|
await resetProcessingJob();
|
||||||
@@ -536,14 +552,14 @@ connectToDatabase(connectionUrl, options)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// console.log('checkdir', folderprof);
|
// console.log('checkdir', folderprof);
|
||||||
if (!await tools.isFileExistsAsync(folderprof)) {
|
if (!(await tools.isFileExistsAsync(folderprof))) {
|
||||||
console.log('*** Creadir', folderprof);
|
console.log('*** Creadir', folderprof);
|
||||||
await fs.mkdirSync(folderprof);
|
await fs.mkdirSync(folderprof);
|
||||||
}
|
}
|
||||||
|
|
||||||
folderprof = dir + 'profile/' + myuser.username + '/' + table;
|
folderprof = dir + 'profile/' + myuser.username + '/' + table;
|
||||||
// console.log('checkdir', folderprof);
|
// console.log('checkdir', folderprof);
|
||||||
if (!await tools.isFileExistsAsync(folderprof)) {
|
if (!(await tools.isFileExistsAsync(folderprof))) {
|
||||||
console.log('creadir', folderprof);
|
console.log('creadir', folderprof);
|
||||||
await fs.mkdirSync(folderprof);
|
await fs.mkdirSync(folderprof);
|
||||||
}
|
}
|
||||||
@@ -559,18 +575,18 @@ connectToDatabase(connectionUrl, options)
|
|||||||
// console.log('file', file);
|
// console.log('file', file);
|
||||||
// console.log('filefrom', filefrom);
|
// console.log('filefrom', filefrom);
|
||||||
|
|
||||||
if (!await tools.isFileExistsAsync(file)) {
|
if (!(await tools.isFileExistsAsync(file))) {
|
||||||
// non esiste
|
// non esiste
|
||||||
console.log('non esiste', file);
|
console.log('non esiste', file);
|
||||||
console.log(' filefrom', filefrom);
|
console.log(' filefrom', filefrom);
|
||||||
console.log(' filefrom2', filefrom2);
|
console.log(' filefrom2', filefrom2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await tools.isFileExistsAsync(file) && await tools.isFileExistsAsync(filefrom)) {
|
if (!(await tools.isFileExistsAsync(file)) && (await tools.isFileExistsAsync(filefrom))) {
|
||||||
console.log('@@@@@@ copia file:', filefrom, 'a', file);
|
console.log('@@@@@@ copia file:', filefrom, 'a', file);
|
||||||
tools.copy(filefrom, file);
|
tools.copy(filefrom, file);
|
||||||
}
|
}
|
||||||
if (!await tools.isFileExistsAsync(file) && await tools.isFileExistsAsync(filefrom2)) {
|
if (!(await tools.isFileExistsAsync(file)) && (await tools.isFileExistsAsync(filefrom2))) {
|
||||||
console.log('@@@@@@ copia file 2:', filefrom2, 'a', file);
|
console.log('@@@@@@ copia file 2:', filefrom2, 'a', file);
|
||||||
tools.copy(filefrom2, file);
|
tools.copy(filefrom2, file);
|
||||||
}
|
}
|
||||||
@@ -693,10 +709,10 @@ connectToDatabase(connectionUrl, options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verifica esistenza file
|
// Verifica esistenza file
|
||||||
if (!await tools.isFileExistsAsync(keyPath)) {
|
if (!(await tools.isFileExistsAsync(keyPath))) {
|
||||||
throw new Error(`Chiave privata non trovata: ${keyPath}`);
|
throw new Error(`Chiave privata non trovata: ${keyPath}`);
|
||||||
}
|
}
|
||||||
if (!await tools.isFileExistsAsync(certPath)) {
|
if (!(await tools.isFileExistsAsync(certPath))) {
|
||||||
throw new Error(`Certificato non trovato: ${certPath}`);
|
throw new Error(`Certificato non trovato: ${certPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,8 +788,13 @@ connectToDatabase(connectionUrl, options)
|
|||||||
|
|
||||||
function buildAllowedOrigins(domains, domainsAllowed, isProduction) {
|
function buildAllowedOrigins(domains, domainsAllowed, isProduction) {
|
||||||
if (!isProduction) {
|
if (!isProduction) {
|
||||||
return ['https://localhost:3000', 'https://localhost:8089', 'https://localhost:8084',
|
return [
|
||||||
'https://localhost:8088', 'https://localhost:8099'];
|
'https://localhost:3000',
|
||||||
|
'https://localhost:8089',
|
||||||
|
'https://localhost:8084',
|
||||||
|
'https://localhost:8088',
|
||||||
|
'https://localhost:8099',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseOrigins = domains.flatMap((domain) => [
|
const baseOrigins = domains.flatMap((domain) => [
|
||||||
@@ -804,7 +825,7 @@ connectToDatabase(connectionUrl, options)
|
|||||||
|
|
||||||
const originValidator = (origin, callback) => {
|
const originValidator = (origin, callback) => {
|
||||||
if (!origin) {
|
if (!origin) {
|
||||||
console.log('✅ Origin undefined or empty — allowing');
|
// console.log('✅ Origin undefined or empty — allowing');
|
||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +968,7 @@ connectToDatabase(connectionUrl, options)
|
|||||||
if (scriptProcess) scriptProcess.kill();
|
if (scriptProcess) scriptProcess.kill();
|
||||||
|
|
||||||
const scriptPath = path.join(__dirname, '..', '..', parsed.scriptName);
|
const scriptPath = path.join(__dirname, '..', '..', parsed.scriptName);
|
||||||
if (!await tools.isFileExistsAsync(scriptPath)) {
|
if (!(await tools.isFileExistsAsync(scriptPath))) {
|
||||||
return ws.send(JSON.stringify({ type: 'error', data: 'Script non trovato o non autorizzato' }));
|
return ws.send(JSON.stringify({ type: 'error', data: 'Script non trovato o non autorizzato' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -361,84 +361,88 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const user of arrusers) {
|
for (const user of arrusers) {
|
||||||
const mytitle = await tools.convertSpecialTags(user, params.title);
|
try {
|
||||||
const mycontent = await tools.convertSpecialTags(
|
const mytitle = await tools.convertSpecialTags(user, params.title);
|
||||||
user,
|
const mycontent = await tools.convertSpecialTags(
|
||||||
params.textcontent_Telegram ? params.textcontent_Telegram : params.content
|
user,
|
||||||
);
|
params.textcontent_Telegram ? params.textcontent_Telegram : params.content
|
||||||
|
);
|
||||||
|
|
||||||
let usernotifprofile = null;
|
let usernotifprofile = null;
|
||||||
if (user.profile.notifs)
|
if (user.profile.notifs)
|
||||||
usernotifprofile = user.profile.notifs.find((notif) => notif.dir === params.typenotif);
|
usernotifprofile = user.profile.notifs.find((notif) => notif.dir === params.typenotif);
|
||||||
|
|
||||||
let risult = null;
|
let risult = null;
|
||||||
|
|
||||||
let sendmsg = false;
|
let sendmsg = false;
|
||||||
|
|
||||||
if (params.typenotif === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
|
if (params.typenotif === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
|
||||||
if (
|
if (
|
||||||
!usernotifprofile ||
|
!usernotifprofile ||
|
||||||
(usernotifprofile &&
|
(usernotifprofile &&
|
||||||
tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))
|
tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))
|
||||||
) {
|
) {
|
||||||
|
sendmsg = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
sendmsg = true;
|
sendmsg = true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sendmsg = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sendmsg) {
|
if (sendmsg) {
|
||||||
if (params.sendreally) {
|
if (params.sendreally) {
|
||||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
||||||
const myparam = { ...params };
|
const myparam = { ...params };
|
||||||
risult = await tools
|
risult = await tools
|
||||||
.sendNotificationToUser(
|
.sendNotificationToUser(
|
||||||
user._id,
|
user._id,
|
||||||
mytitle,
|
mytitle,
|
||||||
mycontent,
|
mycontent,
|
||||||
myparam.openUrl,
|
myparam.openUrl,
|
||||||
myparam.openUrl2,
|
myparam.openUrl2,
|
||||||
myparam.tag,
|
myparam.tag,
|
||||||
myparam.actions,
|
myparam.actions,
|
||||||
myparam.id
|
myparam.id
|
||||||
)
|
)
|
||||||
.then((ris) => {})
|
.then((ris) => { })
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
|
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
|
||||||
const telegid = user.profile.teleg_id;
|
const telegid = user.profile.teleg_id;
|
||||||
|
|
||||||
text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM);
|
text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM);
|
||||||
if (telegid > 0) {
|
if (telegid > 0) {
|
||||||
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(
|
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(
|
||||||
idapp,
|
idapp,
|
||||||
telegid,
|
telegid,
|
||||||
text,
|
text,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
params.img
|
params.img
|
||||||
);
|
);
|
||||||
await tools.snooze(25);
|
await tools.snooze(25);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (risult && (risult.text || risult.caption)) textsent = risult.text || risult.caption;
|
if (risult && (risult.text || risult.caption)) textsent = risult.text || risult.caption;
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
numrec++;
|
numrec++;
|
||||||
if (params.sendreally && risult) {
|
if (params.sendreally && risult) {
|
||||||
nummsgsent++;
|
nummsgsent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nummsgsent > 0 && nummsgsent % 100 === 0) {
|
if (nummsgsent > 0 && nummsgsent % 100 === 0) {
|
||||||
console.log('Inviati ', nummsgsent, 'messaggi...');
|
console.log('Inviati ', nummsgsent, 'messaggi...');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Errore Invio Notifica a ', user.username, 'Err:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user