Settore se compariva "Tutti", veniva selezionato erroneamente di default -100
Risolto caricamento immagini Cliccando sull'immagine del profilo, nella Card, non si apre il Profilo Aggiunto "Estero" e "On Line" sul campo Comune. Orientamento dell'Immagine. viene storta una volta ridimensionata. Al momento della registrazione, dal BOT, in automatico viene presa l'immagine di Telegram e salvata sul proprio profilo della APP.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
=`New Registration of ${name} ${surname} (${username}) in ${nomeapp}`
|
=`New Reg. of ${name} ${surname} (${username}) in ${nomeapp} - invited by ${aportador_solidario}`
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
=`Nuova Registrazione di ${name} ${surname} (${username}) su ${nomeapp}`
|
=`++ Reg. di ${name} ${surname} (${username}) su ${nomeapp} - invitato da ${aportador_solidario}`
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"formidable": "^1.2.2",
|
"formidable": "^1.2.2",
|
||||||
"i18n": "^0.13.3",
|
"i18n": "^0.13.3",
|
||||||
|
"image-downloader": "^4.1.0",
|
||||||
"jade": "^1.11.0",
|
"jade": "^1.11.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
|||||||
@@ -1882,6 +1882,21 @@ UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
|
||||||
|
const User = this;
|
||||||
|
|
||||||
|
const fields_to_update = {
|
||||||
|
'profile.img': imgpic,
|
||||||
|
};
|
||||||
|
|
||||||
|
return User.findOneAndUpdate({
|
||||||
|
idapp, username,
|
||||||
|
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||||
|
return !!record;
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
|
UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
|
|||||||
@@ -89276,5 +89276,27 @@ module.exports = {
|
|||||||
abitanti: '',
|
abitanti: '',
|
||||||
country: 'RSM',
|
country: 'RSM',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
_id: 8118,
|
||||||
|
istat: '',
|
||||||
|
comune: 'Estero',
|
||||||
|
prov: 'EST',
|
||||||
|
reg: 'EST',
|
||||||
|
pref: '',
|
||||||
|
cap: '',
|
||||||
|
abitanti: '',
|
||||||
|
country: 'EST',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_id: 8119,
|
||||||
|
istat: '',
|
||||||
|
comune: 'On Line',
|
||||||
|
prov: 'ONL',
|
||||||
|
reg: 'ONL',
|
||||||
|
pref: '',
|
||||||
|
cap: '',
|
||||||
|
abitanti: '',
|
||||||
|
country: 'ONL',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -111,5 +111,7 @@ module.exports = {
|
|||||||
{_id: 109, reg: 'VEN', prov: 'VI', descr: 'Vicenza'},
|
{_id: 109, reg: 'VEN', prov: 'VI', descr: 'Vicenza'},
|
||||||
{_id: 110, reg: 'LAZ', prov: 'VT', descr: 'Viterbo'},
|
{_id: 110, reg: 'LAZ', prov: 'VT', descr: 'Viterbo'},
|
||||||
{_id: 111, reg: 'RSM', prov: 'RSM', descr: 'Repubblica di San Marino'},
|
{_id: 111, reg: 'RSM', prov: 'RSM', descr: 'Repubblica di San Marino'},
|
||||||
|
{_id: 112, reg: 'EST', prov: 'EST', descr: 'Estero'},
|
||||||
|
{_id: 113, reg: 'ONL', prov: 'ONL', descr: 'On Line'},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1369,7 +1369,7 @@ function uploadFile(req, res, version) {
|
|||||||
|
|
||||||
form.on('file', async function(name, file) {
|
form.on('file', async function(name, file) {
|
||||||
try {
|
try {
|
||||||
console.log('Uploaded ' + file.name);
|
console.log('1) Uploading ' + file.name);
|
||||||
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
||||||
server_constants.DIR_UPLOAD + '/' + dir;
|
server_constants.DIR_UPLOAD + '/' + dir;
|
||||||
|
|
||||||
@@ -1388,20 +1388,13 @@ function uploadFile(req, res, version) {
|
|||||||
let newname = mydir + '/' + file.name;
|
let newname = mydir + '/' + file.name;
|
||||||
let resized_img = mydir + '/' + server_constants.PREFIX_IMG + filename;
|
let resized_img = mydir + '/' + server_constants.PREFIX_IMG + filename;
|
||||||
|
|
||||||
console.log('move from ', file.path, 'to :', newname);
|
|
||||||
|
|
||||||
// For local: ... resolve this... sending through the static folder...
|
|
||||||
// res.sendFile(path.resolve(filename));
|
|
||||||
|
|
||||||
oldpath = file.path;
|
oldpath = file.path;
|
||||||
// newname = '/home/paolo/Documents/prova.png'
|
|
||||||
file.path = newname;
|
file.path = newname;
|
||||||
|
|
||||||
// Move in the folder application !
|
// Move in the folder application !
|
||||||
// tools.move(oldpath, newname, (err) => {
|
|
||||||
tools.move(oldpath, newname, (err) => {
|
tools.move(oldpath, newname, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('err:', err);
|
console.log('err uploadDir:', err);
|
||||||
res.status(400).send();
|
res.status(400).send();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -1411,21 +1404,33 @@ function uploadFile(req, res, version) {
|
|||||||
server_constants.PREFIX_IMG_SMALL +
|
server_constants.PREFIX_IMG_SMALL +
|
||||||
tools.extractFileName(newname);
|
tools.extractFileName(newname);
|
||||||
// SMALL
|
// SMALL
|
||||||
sharp(newname).
|
|
||||||
|
// questa opzione 'failOnError' serve per risolvere l'errore (Error: VipsJpeg: Invalid SOS parameters for sequential JPEG
|
||||||
|
sharp(newname, { failOnError: false }).
|
||||||
resize(64, 64).
|
resize(64, 64).
|
||||||
|
withMetadata().
|
||||||
toFile(resized_img_small);
|
toFile(resized_img_small);
|
||||||
|
|
||||||
// MEDIUM
|
// MEDIUM
|
||||||
let resized_img = tools.extractFilePath(newname) + '/' +
|
let resized_img = tools.extractFilePath(newname) + '/' + server_constants.PREFIX_IMG + tools.extractFileName(newname);
|
||||||
server_constants.PREFIX_IMG + tools.extractFileName(newname);
|
sharp(newname, { failOnError: false }).
|
||||||
sharp(newname).
|
resize( {
|
||||||
resize(512, 512).
|
width: 512,
|
||||||
toFile(resized_img, function(err) {
|
height: 512,
|
||||||
|
fit: sharp.fit.cover,
|
||||||
|
position: sharp.strategy.entropy
|
||||||
|
})
|
||||||
|
.withMetadata()
|
||||||
|
.toFile(resized_img, function(err) {
|
||||||
|
|
||||||
|
// console.log('3) Ridimensionata Immagine ' + newname, 'in', resized_img);
|
||||||
|
|
||||||
if (tools.isFileExists(resized_img)) {
|
if (tools.isFileExists(resized_img)) {
|
||||||
|
// console.log('4) Cancella l \'immagine grande originale:', newname);
|
||||||
// DELETE THE ORIGINAL BIG
|
// DELETE THE ORIGINAL BIG
|
||||||
tools.delete(newname, false, () => {});
|
tools.delete(newname, false, () => {});
|
||||||
|
|
||||||
|
// console.log('5) Rinomina l\'immagine Media da', resized_img, 'a:', newname);
|
||||||
// RENAME THE MEDIUM IN THE ORIGINAL NAME
|
// RENAME THE MEDIUM IN THE ORIGINAL NAME
|
||||||
tools.move(resized_img, newname, (err) => {
|
tools.move(resized_img, newname, (err) => {
|
||||||
if (err)
|
if (err)
|
||||||
@@ -1439,12 +1444,12 @@ function uploadFile(req, res, version) {
|
|||||||
console.error('Error Upload: ', err);
|
console.error('Error Upload: ', err);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('newname', e);
|
console.error('Error Upload(2) ', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.end();
|
res.end();
|
||||||
console.log('res.end');
|
// console.log('res.end');
|
||||||
// return res.send({filename: newname });
|
// return res.send({filename: newname });
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -1456,7 +1461,7 @@ function uploadFile(req, res, version) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
form.on('end', function() {
|
form.on('end', function() {
|
||||||
console.log('-> upload done');
|
// console.log('-> upload done');
|
||||||
});
|
});
|
||||||
|
|
||||||
form.on('aborted', () => {
|
form.on('aborted', () => {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ require('./db/mongoose');
|
|||||||
|
|
||||||
const {Settings} = require('./models/settings');
|
const {Settings} = require('./models/settings');
|
||||||
|
|
||||||
|
const globalTables = require('./tools/globalTables');
|
||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
|
||||||
// OBTAIN
|
// OBTAIN
|
||||||
@@ -241,6 +243,8 @@ async function myLoad() {
|
|||||||
|
|
||||||
async function mystart() {
|
async function mystart() {
|
||||||
|
|
||||||
|
await estraiTutteLeImmagini();
|
||||||
|
|
||||||
if (process.env.PROD !== 1) {
|
if (process.env.PROD !== 1) {
|
||||||
|
|
||||||
testmsgwebpush();
|
testmsgwebpush();
|
||||||
@@ -424,6 +428,104 @@ async function inizia() {
|
|||||||
// console.log(link2);
|
// console.log(link2);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
async function estraiImmagini(table) {
|
||||||
|
const {User} = require('./models/user');
|
||||||
|
|
||||||
|
let idapp = '13';
|
||||||
|
|
||||||
|
let arrlist;
|
||||||
|
|
||||||
|
const mytable = globalTables.getTableByTableName(table);
|
||||||
|
if (!mytable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
console.log('INIZIO - estraiImmagini', table);
|
||||||
|
|
||||||
|
arrlist = await mytable.find({idapp}).lean();
|
||||||
|
|
||||||
|
let file = '';
|
||||||
|
let filetocheck = '';
|
||||||
|
let dirmain = '';
|
||||||
|
let filefrom = '';
|
||||||
|
let filefrom2 = '';
|
||||||
|
let dir = tools.getdirByIdApp(idapp) + dirmain + '/upload/';
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!tools.sulServer()) {
|
||||||
|
dirmain = '/public';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const rec of arrlist) {
|
||||||
|
const myuser = await User.findOne({idapp, _id: rec.userId}).lean();
|
||||||
|
if (myuser) {
|
||||||
|
const myphotos = rec.photos;
|
||||||
|
|
||||||
|
if (myphotos.length > 0) {
|
||||||
|
let folderprof = dir + 'profile/' + myuser.username;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// console.log('checkdir', folderprof);
|
||||||
|
if (!fs.existsSync(folderprof)) {
|
||||||
|
console.log('*** Creadir', folderprof)
|
||||||
|
fs.mkdirSync(folderprof);
|
||||||
|
}
|
||||||
|
|
||||||
|
folderprof = dir + 'profile/' + myuser.username + '/' + table;
|
||||||
|
// console.log('checkdir', folderprof);
|
||||||
|
if (!fs.existsSync(folderprof)) {
|
||||||
|
console.log('creadir', folderprof)
|
||||||
|
fs.mkdirSync(folderprof);
|
||||||
|
}
|
||||||
|
}catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const photo of myphotos) {
|
||||||
|
|
||||||
|
if (photo.imagefile) {
|
||||||
|
file = dir + 'profile/' + myuser.username + '/' + table + '/' +
|
||||||
|
photo.imagefile;
|
||||||
|
filefrom = dir + 'profile/undefined/' + table + '/' + photo.imagefile;
|
||||||
|
filefrom2 = dir + 'profile/' + myuser.username + '/' + photo.imagefile;
|
||||||
|
|
||||||
|
// console.log('file', file);
|
||||||
|
// console.log('filefrom', filefrom);
|
||||||
|
|
||||||
|
if (!tools.isFileExists(file)){
|
||||||
|
// non esiste
|
||||||
|
console.log('non esiste', file);
|
||||||
|
console.log(' filefrom', filefrom);
|
||||||
|
console.log(' filefrom2', filefrom2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tools.isFileExists(file) && tools.isFileExists(filefrom)) {
|
||||||
|
console.log('@@@@@@ copia file:', filefrom, 'a', file);
|
||||||
|
tools.copy(filefrom, file);
|
||||||
|
}
|
||||||
|
if (!tools.isFileExists(file) && tools.isFileExists(filefrom2)) {
|
||||||
|
console.log('@@@@@@ copia file 2:', filefrom2, 'a', file);
|
||||||
|
tools.copy(filefrom2, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('FINE - estraiImmagini', table);
|
||||||
|
}catch (e) {
|
||||||
|
console.error('e', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function estraiTutteLeImmagini() {
|
||||||
|
|
||||||
|
await estraiImmagini('myskills');
|
||||||
|
await estraiImmagini('mygoods');
|
||||||
|
await estraiImmagini('mybachecas');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function faitest() {
|
async function faitest() {
|
||||||
// console.log('Fai Test:')
|
// console.log('Fai Test:')
|
||||||
|
|
||||||
|
|||||||
@@ -133,12 +133,12 @@ MsgBot = {
|
|||||||
'grazie😘'],
|
'grazie😘'],
|
||||||
PRINCIPE_AZZURRO: ['principe azzurro'],
|
PRINCIPE_AZZURRO: ['principe azzurro'],
|
||||||
COSE_COVID: [
|
COSE_COVID: [
|
||||||
'cos\'è il covid',
|
'cos\'è il covid',
|
||||||
'cosa è il covid',
|
'cosa è il covid',
|
||||||
],
|
],
|
||||||
COVID: [
|
COVID: [
|
||||||
'covid',
|
'covid',
|
||||||
],
|
],
|
||||||
SPOSAMI: [
|
SPOSAMI: [
|
||||||
'sposami',
|
'sposami',
|
||||||
'vuoi sposar',
|
'vuoi sposar',
|
||||||
@@ -149,7 +149,11 @@ MsgBot = {
|
|||||||
'mi sposi'],
|
'mi sposi'],
|
||||||
CHE_TEMPO_FA: ['che tempo'],
|
CHE_TEMPO_FA: ['che tempo'],
|
||||||
NON_TROO_INVITATI: ['non trovo invitati', 'non riesco a trovare invitati'],
|
NON_TROO_INVITATI: ['non trovo invitati', 'non riesco a trovare invitati'],
|
||||||
TROVAMI_UN_UOMO_DONNA: ['trovami un uomo', 'trovami una donna', 'esiste una donna per me', 'esiste un uomo per me'],
|
TROVAMI_UN_UOMO_DONNA: [
|
||||||
|
'trovami un uomo',
|
||||||
|
'trovami una donna',
|
||||||
|
'esiste una donna per me',
|
||||||
|
'esiste un uomo per me'],
|
||||||
PAROLACCE: [
|
PAROLACCE: [
|
||||||
'stronz',
|
'stronz',
|
||||||
'fanculo',
|
'fanculo',
|
||||||
@@ -242,6 +246,7 @@ const Menu = {
|
|||||||
MSG_TO_USER: 'sendmsgto',
|
MSG_TO_USER: 'sendmsgto',
|
||||||
ADMIN: emoji.get('information_desk_person') + ' Admin',
|
ADMIN: emoji.get('information_desk_person') + ' Admin',
|
||||||
ALTRO: emoji.get('newspaper') + ' Altro',
|
ALTRO: emoji.get('newspaper') + ' Altro',
|
||||||
|
SETPICPROFILE: '🖼 SetPicProfile',
|
||||||
// MSG_TO_NAVE: emoji.get('incoming_envelope') + 'Msg_to_Navi',
|
// MSG_TO_NAVE: emoji.get('incoming_envelope') + 'Msg_to_Navi',
|
||||||
// MSG_NO_7_REQ: emoji.get('incoming_envelope') + 'No 7 Req.',
|
// MSG_NO_7_REQ: emoji.get('incoming_envelope') + 'No 7 Req.',
|
||||||
// MSG_NO_9_REQ: emoji.get('incoming_envelope') + 'No 9 Req',
|
// MSG_NO_9_REQ: emoji.get('incoming_envelope') + 'No 9 Req',
|
||||||
@@ -464,9 +469,9 @@ const txt = {
|
|||||||
'Ti sei correttamente verificato con il BOT. ' +
|
'Ti sei correttamente verificato con il BOT. ' +
|
||||||
'\nSono il tuo assistente virtuale (BOT).\n\n' +
|
'\nSono il tuo assistente virtuale (BOT).\n\n' +
|
||||||
'Questa chat ti servirà per interagire con la Piattaforma e per ricevere delle notifiche Personali.\n' +
|
'Questa chat ti servirà per interagire con la Piattaforma e per ricevere delle notifiche Personali.\n' +
|
||||||
''+
|
'' +
|
||||||
'(🆘 Per Aiuti, guarda il menu qui sotto)\n\n' +
|
'(🆘 Per Aiuti, guarda il menu qui sotto)\n\n' +
|
||||||
''+
|
'' +
|
||||||
'😍😍😍 Ora sei pronto per Entrare nella APP!\n' +
|
'😍😍😍 Ora sei pronto per Entrare nella APP!\n' +
|
||||||
'👉🏻 Clicca qui: %s',
|
'👉🏻 Clicca qui: %s',
|
||||||
MSG_SET_USERNAME: '✨✨✨✨✨✨✨✨✨✨\n' +
|
MSG_SET_USERNAME: '✨✨✨✨✨✨✨✨✨✨\n' +
|
||||||
@@ -484,11 +489,12 @@ const txt = {
|
|||||||
'Ora puoi proseguire sulla APP.',
|
'Ora puoi proseguire sulla APP.',
|
||||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
|
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
|
||||||
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
|
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
|
||||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
|
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
|
||||||
|
' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
|
||||||
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍♂️ Abilita Nuova Registrazione: %s',
|
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍♂️ Abilita Nuova Registrazione: %s',
|
||||||
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
|
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
|
||||||
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!\n' +
|
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!\n' +
|
||||||
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
|
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
|
||||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||||
@@ -514,7 +520,8 @@ const txt_es = {
|
|||||||
emo.EXCLAMATION_MARK +
|
emo.EXCLAMATION_MARK +
|
||||||
'\nComprueba en el sitio %s y reescribe el nuevo código de 6 dígitos.',
|
'\nComprueba en el sitio %s y reescribe el nuevo código de 6 dígitos.',
|
||||||
MSG_VERIFY_OK: emoji.get('grinning') +
|
MSG_VERIFY_OK: emoji.get('grinning') +
|
||||||
' Bienvenido %s! Ha verificado correctamente con el BOT. ' + emo.GREEN_HEART,
|
' Bienvenido %s! Ha verificado correctamente con el BOT. ' +
|
||||||
|
emo.GREEN_HEART,
|
||||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Error al guardar en el servidor. Inténtalo de nuevo más tarde.',
|
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Error al guardar en el servidor. Inténtalo de nuevo más tarde.',
|
||||||
MSG_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
|
MSG_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
|
||||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
|
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
|
||||||
@@ -728,13 +735,16 @@ module.exports = {
|
|||||||
aportador = ` (${userdest})`;
|
aportador = ` (${userdest})`;
|
||||||
NameFrom += aportador;
|
NameFrom += aportador;
|
||||||
} else {
|
} else {
|
||||||
aportador = mylocalsconf.user.aportador_solidario_nome_completo ? mylocalsconf.user.aportador_solidario_nome_completo : mylocalsconf.user.aportador_solidario;
|
aportador = mylocalsconf.user.aportador_solidario_nome_completo
|
||||||
|
? mylocalsconf.user.aportador_solidario_nome_completo
|
||||||
|
: mylocalsconf.user.aportador_solidario;
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
if (phase === this.phase.REGISTRATION) {
|
if (phase === this.phase.REGISTRATION) {
|
||||||
|
|
||||||
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Bot_ToManagers)) {
|
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp,
|
||||||
|
shared_consts.ConfSite.Notif_Reg_Bot_ToManagers)) {
|
||||||
if (userdest) {
|
if (userdest) {
|
||||||
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp,
|
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp,
|
||||||
userdest, true) + aportador;
|
userdest, true) + aportador;
|
||||||
@@ -761,7 +771,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (phase === this.phase.REGISTRATION) {
|
if (phase === this.phase.REGISTRATION) {
|
||||||
await this.askConfirmationUserRegistration(mylocalsconf.idapp, shared_consts.CallFunz.REGISTRATION,
|
await this.askConfirmationUserRegistration(mylocalsconf.idapp,
|
||||||
|
shared_consts.CallFunz.REGISTRATION,
|
||||||
mylocalsconf.user, userdest, langdest);
|
mylocalsconf.user, userdest, langdest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +814,8 @@ module.exports = {
|
|||||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMsgTelegramToTheManagers: async function(idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
|
sendMsgTelegramToTheManagers: async function(
|
||||||
|
idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
|
||||||
|
|
||||||
tools.writeManagersLog(text);
|
tools.writeManagersLog(text);
|
||||||
|
|
||||||
@@ -881,7 +893,6 @@ module.exports = {
|
|||||||
msg = cl.convertSpecialTags(rec.user, msg);
|
msg = cl.convertSpecialTags(rec.user, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!!mydata.flotta) {
|
if (!!mydata.flotta) {
|
||||||
// SOSTITUISCI LE PAROLE CHIAVI
|
// SOSTITUISCI LE PAROLE CHIAVI
|
||||||
if (!!mydata.flotta.date_start)
|
if (!!mydata.flotta.date_start)
|
||||||
@@ -1013,7 +1024,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!!idteleg) {
|
if (!!idteleg) {
|
||||||
strout += '\n (' + index + ') ' + user.username + ' (' + user.name + ' ' + user.surname + ':';
|
strout += '\n (' + index + ') ' + user.username + ' (' +
|
||||||
|
user.name + ' ' + user.surname + ':';
|
||||||
if (mydata.inviareale) {
|
if (mydata.inviareale) {
|
||||||
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg,
|
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg,
|
||||||
undefined, undefined, true);
|
undefined, undefined, true);
|
||||||
@@ -1208,20 +1220,22 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setVerifiedReg: async function (idapp, lang, usernameorig, usernameDest) {
|
setVerifiedReg: async function(idapp, lang, usernameorig, usernameDest) {
|
||||||
try {
|
try {
|
||||||
await User.setVerifiedByAportador(idapp, usernameDest, true);
|
await User.setVerifiedByAportador(idapp, usernameDest, true);
|
||||||
await User.setFriendsCmd(idapp, usernameorig, usernameDest,
|
await User.setFriendsCmd(idapp, usernameorig, usernameDest,
|
||||||
shared_consts.FRIENDSCMD.SETFRIEND);
|
shared_consts.FRIENDSCMD.SETFRIEND);
|
||||||
|
|
||||||
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'), `${usernameDest}`);
|
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||||
|
`${usernameDest}`);
|
||||||
await local_sendMsgTelegram(idapp, usernameorig, msgDest);
|
await local_sendMsgTelegram(idapp, usernameorig, msgDest);
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
console.log('e', e);
|
console.log('e', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
askConfirmationUserRegistration: async function(idapp, myfunc, myuser, userDest = '', langdest = '') {
|
askConfirmationUserRegistration: async function(
|
||||||
|
idapp, myfunc, myuser, userDest = '', langdest = '') {
|
||||||
|
|
||||||
const cl = getclTelegByidapp(idapp);
|
const cl = getclTelegByidapp(idapp);
|
||||||
|
|
||||||
@@ -1235,11 +1249,14 @@ module.exports = {
|
|||||||
|
|
||||||
if (notask_verif) {
|
if (notask_verif) {
|
||||||
// Non chiedi la verifica Registrazione
|
// Non chiedi la verifica Registrazione
|
||||||
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
|
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest,
|
||||||
|
myuser.username);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const name = myuser.username + (myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '')
|
const name = myuser.username +
|
||||||
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' + myuser.username;
|
(myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '');
|
||||||
|
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' +
|
||||||
|
myuser.username;
|
||||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||||
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
|
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
|
||||||
myuser.email);
|
myuser.email);
|
||||||
@@ -1264,7 +1281,8 @@ module.exports = {
|
|||||||
// Invia Msg
|
// Invia Msg
|
||||||
if (domanda) {
|
if (domanda) {
|
||||||
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
||||||
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda, undefined, undefined, true, keyb);
|
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
|
||||||
|
undefined, undefined, true, keyb);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -1472,7 +1490,8 @@ class Telegram {
|
|||||||
msg = msg.replace('{username}', user.username);
|
msg = msg.replace('{username}', user.username);
|
||||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||||
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
||||||
msg = msg.replace('{aportador}', user.aportador_solidario ? user.aportador_solidario : '');
|
msg = msg.replace('{aportador_solidario}',
|
||||||
|
user.aportador_solidario ? user.aportador_solidario : '');
|
||||||
if (!!user.profile.link_payment)
|
if (!!user.profile.link_payment)
|
||||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||||
if (!!user.profile.revolut)
|
if (!!user.profile.revolut)
|
||||||
@@ -1490,14 +1509,13 @@ class Telegram {
|
|||||||
// const cl = getclTelegByidapp(user.idapp);
|
// const cl = getclTelegByidapp(user.idapp);
|
||||||
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
||||||
|
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async IsTesto(msg) {
|
async IsTesto(msg) {
|
||||||
|
|
||||||
let risp = '';
|
let risp = '';
|
||||||
@@ -1567,15 +1585,21 @@ class Telegram {
|
|||||||
|
|
||||||
if (rec.status === Status.VERIFIED) {
|
if (rec.status === Status.VERIFIED) {
|
||||||
if (rec.user) {
|
if (rec.user) {
|
||||||
if (rec.user.profile.username_telegram && msg.from.id > 0 && !msg.from.username) {
|
if (rec.user.profile.username_telegram && msg.from.id > 0 &&
|
||||||
rec.user.profile.username_telegram = msg.from.username
|
!msg.from.username) {
|
||||||
await User.setUsernameTelegram(this.idapp, rec.user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
|
rec.user.profile.username_telegram = msg.from.username;
|
||||||
|
await User.setUsernameTelegram(this.idapp, rec.user._id,
|
||||||
|
msg.from.username || '', msg.from.first_name || '',
|
||||||
|
msg.from.last_name || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rec.user.profile.username_telegram && msg.from.username) {
|
if (!rec.user.profile.username_telegram && msg.from.username) {
|
||||||
rec.user.profile.username_telegram = msg.from.username
|
rec.user.profile.username_telegram = msg.from.username;
|
||||||
await User.setUsernameTelegram(this.idapp, rec.user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
|
await User.setUsernameTelegram(this.idapp, rec.user._id,
|
||||||
this.sendMsg(msg.from.id, printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
|
msg.from.username || '', msg.from.first_name || '',
|
||||||
|
msg.from.last_name || '');
|
||||||
|
this.sendMsg(msg.from.id,
|
||||||
|
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
|
||||||
} else {
|
} else {
|
||||||
if (!rec.user.profile.username_telegram) {
|
if (!rec.user.profile.username_telegram) {
|
||||||
return this.checkIfUsernameTelegramSet(msg, rec.user);
|
return this.checkIfUsernameTelegramSet(msg, rec.user);
|
||||||
@@ -1677,8 +1701,10 @@ class Telegram {
|
|||||||
} else if (MsgBot.SEI_LIBERO.find((rec) => testo.indexOf(rec) > -1)) {
|
} else if (MsgBot.SEI_LIBERO.find((rec) => testo.indexOf(rec) > -1)) {
|
||||||
risp = 'Io? Sono per la Libertà! ' + emo.JOY +
|
risp = 'Io? Sono per la Libertà! ' + emo.JOY +
|
||||||
'\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
|
'\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
|
||||||
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find((rec) => testo.indexOf(rec) > -1)) {
|
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find(
|
||||||
risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' + emo.DANCER + emo.FIRE;
|
(rec) => testo.indexOf(rec) > -1)) {
|
||||||
|
risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' +
|
||||||
|
emo.DANCER + emo.FIRE;
|
||||||
} else if (MsgBot.FARE_DOMANDA.find((rec) => testo.indexOf(rec) > -1)) {
|
} else if (MsgBot.FARE_DOMANDA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||||
risp = 'Dipende ' + emo.SMILE_STAR + '\nProvaci!';
|
risp = 'Dipende ' + emo.SMILE_STAR + '\nProvaci!';
|
||||||
} else if (MsgBot.DIVENTERO_RICCA.find(
|
} else if (MsgBot.DIVENTERO_RICCA.find(
|
||||||
@@ -1687,7 +1713,8 @@ class Telegram {
|
|||||||
emo.GIFT_HEART;
|
emo.GIFT_HEART;
|
||||||
} else if (MsgBot.MA_ALLORA.find((rec) => testo.indexOf(rec) > -1)) {
|
} else if (MsgBot.MA_ALLORA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||||
risp = 'Ma allora cosa?';
|
risp = 'Ma allora cosa?';
|
||||||
} else if (MsgBot.TROVAMI_UN_UOMO_DONNA.find((rec) => testo.indexOf(rec) > -1)) {
|
} else if (MsgBot.TROVAMI_UN_UOMO_DONNA.find(
|
||||||
|
(rec) => testo.indexOf(rec) > -1)) {
|
||||||
risp = 'Eh non è cosi facile. Ma se t\'impegni a cercare ci riuscirai. Nel frattempo trova la tua strada, fai il tuo percorso interiore, e magari arriva proprio quando meno te l\'aspetti';
|
risp = 'Eh non è cosi facile. Ma se t\'impegni a cercare ci riuscirai. Nel frattempo trova la tua strada, fai il tuo percorso interiore, e magari arriva proprio quando meno te l\'aspetti';
|
||||||
} else if (MsgBot.SEI_LIBERO_STASERA.find(
|
} else if (MsgBot.SEI_LIBERO_STASERA.find(
|
||||||
(rec) => testo.indexOf(rec) > -1)) {
|
(rec) => testo.indexOf(rec) > -1)) {
|
||||||
@@ -1868,7 +1895,7 @@ class Telegram {
|
|||||||
await this.menumsgStaff(msg);
|
await this.menumsgStaff(msg);
|
||||||
} else if (testo === Menu.MSGPAOLO) {
|
} else if (testo === Menu.MSGPAOLO) {
|
||||||
await this.menumsgPaolo(msg);
|
await this.menumsgPaolo(msg);
|
||||||
// } else if (testo === Menu.MSG_NO_7_REQ) {
|
// } else if (testo === Menu.MSG_NO_7_REQ) {
|
||||||
// await this.menumsg_No_7_Req(msg);
|
// await this.menumsg_No_7_Req(msg);
|
||||||
// } else if (testo === Menu.MSG_NO_9_REQ) {
|
// } else if (testo === Menu.MSG_NO_9_REQ) {
|
||||||
// await this.menumsg_No_9_Req(msg);
|
// await this.menumsg_No_9_Req(msg);
|
||||||
@@ -1876,10 +1903,12 @@ class Telegram {
|
|||||||
// await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
|
// await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
|
||||||
// } else if (cmd1 === Menu.MSG_TO_NAVE) {
|
// } else if (cmd1 === Menu.MSG_TO_NAVE) {
|
||||||
// await this.menumsg_to_Nave(msg, cmd2);
|
// await this.menumsg_to_Nave(msg, cmd2);
|
||||||
// } else if (testo === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
|
// } else if (testo === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
|
||||||
// await this.menumsg_Si_Invitati_No_7Req(msg);
|
// await this.menumsg_Si_Invitati_No_7Req(msg);
|
||||||
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||||
await this.menumsg_A_Utente(msg);
|
await this.menumsg_A_Utente(msg);
|
||||||
|
} else if (testo === Menu.SETPICPROFILE) {
|
||||||
|
await this.setPhotoProfile(rec, msg);
|
||||||
} else if (this.isSelMenu(msg, testo, 'INDIETRO') ||
|
} else if (this.isSelMenu(msg, testo, 'INDIETRO') ||
|
||||||
(testo === Menu.it.INDIETRO)) {
|
(testo === Menu.it.INDIETRO)) {
|
||||||
await this.msgScegliMenu(msg);
|
await this.msgScegliMenu(msg);
|
||||||
@@ -2298,7 +2327,7 @@ class Telegram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
permitSendMsg(user) {
|
permitSendMsg(user) {
|
||||||
return User.isAdmin(user.perm)
|
return User.isAdmin(user.perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
async menumsgGenerico(msg, dest, username, extraparam) {
|
async menumsgGenerico(msg, dest, username, extraparam) {
|
||||||
@@ -2495,7 +2524,7 @@ class Telegram {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
console.error('e');
|
console.error('e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2521,7 +2550,9 @@ class Telegram {
|
|||||||
if (rec) {
|
if (rec) {
|
||||||
if (code === telegcode) {
|
if (code === telegcode) {
|
||||||
try {
|
try {
|
||||||
await User.setUsernameTelegram(this.idapp, user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
|
await User.setUsernameTelegram(this.idapp, user._id,
|
||||||
|
msg.from.username || '', msg.from.first_name || '',
|
||||||
|
msg.from.last_name || '');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
// let ris = await this.getUser(msg, rec, false);
|
// let ris = await this.getUser(msg, rec, false);
|
||||||
|
|
||||||
@@ -2529,9 +2560,11 @@ class Telegram {
|
|||||||
await User.SetTelegramIdSuccess(this.idapp, user._id,
|
await User.SetTelegramIdSuccess(this.idapp, user._id,
|
||||||
msg.from.id).then((recuser) => {
|
msg.from.id).then((recuser) => {
|
||||||
if (recuser) {
|
if (recuser) {
|
||||||
let name = recuser.name;
|
this.setPhotoProfile(rec, msg);
|
||||||
|
let username = recuser.name;
|
||||||
this.sendMsg(msg.from.id,
|
this.sendMsg(msg.from.id,
|
||||||
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name, tools.getHostByIdApp(this.idapp)));
|
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), username,
|
||||||
|
tools.getHostByIdApp(this.idapp)));
|
||||||
|
|
||||||
this.checkIfUsernameTelegramSet(msg, recuser);
|
this.checkIfUsernameTelegramSet(msg, recuser);
|
||||||
// local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
|
// local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
|
||||||
@@ -3053,9 +3086,11 @@ class Telegram {
|
|||||||
|
|
||||||
// Check if you are Admin
|
// Check if you are Admin
|
||||||
const user = await User.UserByIdTelegram(idapp, id);
|
const user = await User.UserByIdTelegram(idapp, id);
|
||||||
let isAdmin = user ? user.profile.manage_telegram && user.username === 'paoloar77' : false;
|
let isAdmin = user ? user.profile.manage_telegram && user.username ===
|
||||||
|
'paoloar77' : false;
|
||||||
const isManager = user ? user.profile.manage_telegram : false;
|
const isManager = user ? user.profile.manage_telegram : false;
|
||||||
const isVerified = user ? user.profile.teleg_id > 0 && user.verified_by_aportador : false;
|
const isVerified = user ? user.profile.teleg_id > 0 &&
|
||||||
|
user.verified_by_aportador : false;
|
||||||
|
|
||||||
this.menuDb = await MyBot.findAllIdApp(idapp);
|
this.menuDb = await MyBot.findAllIdApp(idapp);
|
||||||
|
|
||||||
@@ -3075,8 +3110,7 @@ class Telegram {
|
|||||||
|| (isVerified && tools.isBitActive(rec.visibility,
|
|| (isVerified && tools.isBitActive(rec.visibility,
|
||||||
shared_consts.VISIB_ONLYIF_VERIFIED))
|
shared_consts.VISIB_ONLYIF_VERIFIED))
|
||||||
|| (rec.visibility === 0))
|
|| (rec.visibility === 0))
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
rec.active_mem = true;
|
rec.active_mem = true;
|
||||||
if (rec.main) {
|
if (rec.main) {
|
||||||
lang = rec.lang;
|
lang = rec.lang;
|
||||||
@@ -3322,7 +3356,7 @@ class Telegram {
|
|||||||
return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
|
return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
|
||||||
ripr_menuPrec);
|
ripr_menuPrec);
|
||||||
}
|
}
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
console.error('Error sendMsg', e);
|
console.error('Error sendMsg', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3340,6 +3374,43 @@ class Telegram {
|
|||||||
return mymenuout;
|
return mymenuout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setPhotoProfile(rec, msg) {
|
||||||
|
try {
|
||||||
|
if (rec.user) {
|
||||||
|
const idapp = this.idapp;
|
||||||
|
const bot = this.bot;
|
||||||
|
const username = rec.user.username;
|
||||||
|
const token = this.token;
|
||||||
|
let myfileprofile = tools.getdirByIdApp(idapp, true) +
|
||||||
|
server_constants.DIR_UPLOAD + '/profile/' + username +'/';
|
||||||
|
let user_profile = bot.getUserProfilePhotos(msg.from.id);
|
||||||
|
user_profile.then(function(res) {
|
||||||
|
if (res.photos[0]) {
|
||||||
|
var file_id = res.photos[0][2].file_id;
|
||||||
|
var file = bot.getFile(file_id);
|
||||||
|
file.then(function(result) {
|
||||||
|
|
||||||
|
const file_path = result.file_path;
|
||||||
|
const photo_url = 'https://api.telegram.org/file/bot' + token +
|
||||||
|
'/' + file_path;
|
||||||
|
let filename = tools.extractFileName(photo_url)
|
||||||
|
myfileprofile += filename;
|
||||||
|
tools.downloadImage(photo_url, myfileprofile).
|
||||||
|
then((ris) => {
|
||||||
|
User.setPicProfile(idapp, username, filename);
|
||||||
|
// console.log('scaricato');
|
||||||
|
});
|
||||||
|
// bot.sendMessage(chatId, photo_url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error setPhotoProfile', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
getInlineKeyboard(lang, arrrisp1, arrrisp2, arrrisp3) {
|
getInlineKeyboard(lang, arrrisp1, arrrisp2, arrrisp3) {
|
||||||
let mykeyb = {
|
let mykeyb = {
|
||||||
parse_mode: 'HTML',
|
parse_mode: 'HTML',
|
||||||
@@ -3577,16 +3648,20 @@ if (true) {
|
|||||||
|
|
||||||
} else if (data.action === InlineConferma.RISPOSTA_SI +
|
} else if (data.action === InlineConferma.RISPOSTA_SI +
|
||||||
shared_consts.CallFunz.REGISTRATION) {
|
shared_consts.CallFunz.REGISTRATION) {
|
||||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||||
|
data.username,
|
||||||
Cmd.VALIDATE_REGISTRATION, true);
|
Cmd.VALIDATE_REGISTRATION, true);
|
||||||
|
|
||||||
await User.setFriendsCmd(user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
await User.setFriendsCmd(user.idapp, data.username,
|
||||||
|
userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
const msgOrig = printf(
|
const msgOrig = printf(
|
||||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'), `${userDest.username}`, tools.getHostByIdApp(user.idapp));
|
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'),
|
||||||
|
`${userDest.username}`, tools.getHostByIdApp(user.idapp));
|
||||||
const msgDest = printf(
|
const msgDest = printf(
|
||||||
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`);
|
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||||
|
`${user.username}`);
|
||||||
|
|
||||||
await local_sendMsgTelegram(user.idapp, data.username,
|
await local_sendMsgTelegram(user.idapp, data.username,
|
||||||
msgOrig);
|
msgOrig);
|
||||||
@@ -3594,8 +3669,10 @@ if (true) {
|
|||||||
msgDest);
|
msgDest);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
} else if (data.action === InlineConferma.RISPOSTA_NO +
|
||||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
shared_consts.CallFunz.REGISTRATION) {
|
||||||
|
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||||
|
data.username,
|
||||||
Cmd.VALIDATE_REGISTRATION, false);
|
Cmd.VALIDATE_REGISTRATION, false);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const Subscription = mongoose.model('subscribers');
|
|||||||
|
|
||||||
const server_constants = require('./server_constants');
|
const server_constants = require('./server_constants');
|
||||||
|
|
||||||
|
const download = require('image-downloader');
|
||||||
|
|
||||||
// SETTINGS WebPush Configuration
|
// SETTINGS WebPush Configuration
|
||||||
const webpush = require('web-push');
|
const webpush = require('web-push');
|
||||||
@@ -880,7 +881,8 @@ module.exports = {
|
|||||||
let actions = [];
|
let actions = [];
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
|
||||||
descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname, arradmins.username);
|
descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname,
|
||||||
|
arradmins.username);
|
||||||
openUrl = '/grp/' + groupname;
|
openUrl = '/grp/' + groupname;
|
||||||
tag = 'reqgroups';
|
tag = 'reqgroups';
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
|
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
|
||||||
@@ -1096,17 +1098,25 @@ module.exports = {
|
|||||||
return myapp.abilitanave;
|
return myapp.abilitanave;
|
||||||
},
|
},
|
||||||
|
|
||||||
getdirByIdApp: function(idapp) {
|
getdirByIdApp: function(idapp, dirmain = false) {
|
||||||
|
|
||||||
|
let mypath = '';
|
||||||
const myapp =
|
const myapp =
|
||||||
this.getApps().find(item => item.idapp === idapp);
|
this.getApps().find(item => item.idapp === idapp);
|
||||||
if (myapp) {
|
if (myapp) {
|
||||||
if (process.env.NODE_ENV === 'test')
|
if (process.env.NODE_ENV === 'test')
|
||||||
return (myapp) ? myapp.dir_test : '';
|
mypath = (myapp) ? myapp.dir_test : '';
|
||||||
else
|
else
|
||||||
return (myapp) ? myapp.dir : '';
|
mypath = (myapp) ? myapp.dir : '';
|
||||||
} else
|
|
||||||
return '';
|
if (dirmain) {
|
||||||
|
if (this.sulServer() !== 1) {
|
||||||
|
mypath += '/public';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mypath;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAdminEmailByIdApp: function(idapp) {
|
getAdminEmailByIdApp: function(idapp) {
|
||||||
@@ -1137,7 +1147,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getAskToVerifyReg: function(idapp) {
|
getAskToVerifyReg: function(idapp) {
|
||||||
return this.getConfSiteOptionEnabledByIdApp(idapp, shared_consts.ConfSite.Need_Aportador_On_DataReg_To_Verify_Reg);
|
return this.getConfSiteOptionEnabledByIdApp(idapp,
|
||||||
|
shared_consts.ConfSite.Need_Aportador_On_DataReg_To_Verify_Reg);
|
||||||
},
|
},
|
||||||
|
|
||||||
isManagAndAdminDifferent(idapp) {
|
isManagAndAdminDifferent(idapp) {
|
||||||
@@ -1177,7 +1188,7 @@ module.exports = {
|
|||||||
return (myapp && myapp.telegram_support_chat)
|
return (myapp && myapp.telegram_support_chat)
|
||||||
? myapp.telegram_support_chat
|
? myapp.telegram_support_chat
|
||||||
: '';
|
: '';
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2118,7 +2129,7 @@ module.exports = {
|
|||||||
const stream = fs.createWriteStream(filename, {flags: 'a'});
|
const stream = fs.createWriteStream(filename, {flags: 'a'});
|
||||||
stream.write('\n' + mystr);
|
stream.write('\n' + mystr);
|
||||||
stream.end();
|
stream.end();
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2180,7 +2191,10 @@ module.exports = {
|
|||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
console.log(' ... File Rinominato', oldPath, 'in:', newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2192,6 +2206,7 @@ module.exports = {
|
|||||||
writeStream.on('error', callback);
|
writeStream.on('error', callback);
|
||||||
|
|
||||||
readStream.on('close', function() {
|
readStream.on('close', function() {
|
||||||
|
console.log('cancella file già copiato', oldPath);
|
||||||
fs.unlink(oldPath, callback);
|
fs.unlink(oldPath, callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2222,8 +2237,13 @@ module.exports = {
|
|||||||
try {
|
try {
|
||||||
let img_small = path.dirname(mypath) + '/' +
|
let img_small = path.dirname(mypath) + '/' +
|
||||||
server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
||||||
fs.unlink(img_small, () => {});
|
fs.unlink(img_small, function(err) {
|
||||||
console.log('delete file', mypath);
|
if (err)
|
||||||
|
console.log('Errore durante la Cancellazione del file', mypath);
|
||||||
|
else
|
||||||
|
console.log('deleted file', mypath);
|
||||||
|
});
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
@@ -2574,7 +2594,7 @@ module.exports = {
|
|||||||
return process.env.LOCALE !== '1';
|
return process.env.LOCALE !== '1';
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshAllTablesInMem(idapp, table){
|
refreshAllTablesInMem(idapp, table) {
|
||||||
const telegrambot = require('../telegram/telegrambot');
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
if (table === shared_consts.TAB_MYBOTS) {
|
if (table === shared_consts.TAB_MYBOTS) {
|
||||||
@@ -2583,6 +2603,15 @@ module.exports = {
|
|||||||
telegrambot.reloadSites();
|
telegrambot.reloadSites();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
|
downloadImage(url, filepath) {
|
||||||
|
|
||||||
|
return download.image({
|
||||||
|
url,
|
||||||
|
dest: filepath
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4663,6 +4663,11 @@ ignore-walk@^3.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
|
|
||||||
|
image-downloader@^4.1.0:
|
||||||
|
version "4.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/image-downloader/-/image-downloader-4.1.0.tgz#ce54bc675e243b24c43ca951a326416d4b7bf675"
|
||||||
|
integrity sha512-S6snaVMg4g08sksTb0ZUQsgQmKo0sv20jJoVtOnSbO/tVC4xcG9DydjLF5ONTKIz3e3qUPnIrMJhU9G124uIfQ==
|
||||||
|
|
||||||
image-size@0.6.1:
|
image-size@0.6.1:
|
||||||
version "0.6.1"
|
version "0.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.1.tgz#98122a562d59dcc097ef1b2c8191866eb8f5d663"
|
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.1.tgz#98122a562d59dcc097ef1b2c8191866eb8f5d663"
|
||||||
|
|||||||
Reference in New Issue
Block a user