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",
|
||||
"formidable": "^1.2.2",
|
||||
"i18n": "^0.13.3",
|
||||
"image-downloader": "^4.1.0",
|
||||
"jade": "^1.11.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"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) {
|
||||
const User = this;
|
||||
|
||||
|
||||
@@ -89276,5 +89276,27 @@ module.exports = {
|
||||
abitanti: '',
|
||||
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: 110, reg: 'LAZ', prov: 'VT', descr: 'Viterbo'},
|
||||
{_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) {
|
||||
try {
|
||||
console.log('Uploaded ' + file.name);
|
||||
console.log('1) Uploading ' + file.name);
|
||||
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
||||
server_constants.DIR_UPLOAD + '/' + dir;
|
||||
|
||||
@@ -1388,20 +1388,13 @@ function uploadFile(req, res, version) {
|
||||
let newname = mydir + '/' + file.name;
|
||||
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;
|
||||
// newname = '/home/paolo/Documents/prova.png'
|
||||
file.path = newname;
|
||||
|
||||
// Move in the folder application !
|
||||
// tools.move(oldpath, newname, (err) => {
|
||||
tools.move(oldpath, newname, (err) => {
|
||||
if (err) {
|
||||
console.log('err:', err);
|
||||
console.log('err uploadDir:', err);
|
||||
res.status(400).send();
|
||||
} else {
|
||||
|
||||
@@ -1411,21 +1404,33 @@ function uploadFile(req, res, version) {
|
||||
server_constants.PREFIX_IMG_SMALL +
|
||||
tools.extractFileName(newname);
|
||||
// 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).
|
||||
withMetadata().
|
||||
toFile(resized_img_small);
|
||||
|
||||
// MEDIUM
|
||||
let resized_img = tools.extractFilePath(newname) + '/' +
|
||||
server_constants.PREFIX_IMG + tools.extractFileName(newname);
|
||||
sharp(newname).
|
||||
resize(512, 512).
|
||||
toFile(resized_img, function(err) {
|
||||
let resized_img = tools.extractFilePath(newname) + '/' + server_constants.PREFIX_IMG + tools.extractFileName(newname);
|
||||
sharp(newname, { failOnError: false }).
|
||||
resize( {
|
||||
width: 512,
|
||||
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)) {
|
||||
// console.log('4) Cancella l \'immagine grande originale:', newname);
|
||||
// DELETE THE ORIGINAL BIG
|
||||
tools.delete(newname, false, () => {});
|
||||
|
||||
// console.log('5) Rinomina l\'immagine Media da', resized_img, 'a:', newname);
|
||||
// RENAME THE MEDIUM IN THE ORIGINAL NAME
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
if (err)
|
||||
@@ -1439,12 +1444,12 @@ function uploadFile(req, res, version) {
|
||||
console.error('Error Upload: ', err);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('newname', e);
|
||||
console.error('Error Upload(2) ', e);
|
||||
}
|
||||
}
|
||||
|
||||
res.end();
|
||||
console.log('res.end');
|
||||
// console.log('res.end');
|
||||
// return res.send({filename: newname });
|
||||
|
||||
});
|
||||
@@ -1456,7 +1461,7 @@ function uploadFile(req, res, version) {
|
||||
});
|
||||
|
||||
form.on('end', function() {
|
||||
console.log('-> upload done');
|
||||
// console.log('-> upload done');
|
||||
});
|
||||
|
||||
form.on('aborted', () => {
|
||||
|
||||
@@ -28,6 +28,8 @@ require('./db/mongoose');
|
||||
|
||||
const {Settings} = require('./models/settings');
|
||||
|
||||
const globalTables = require('./tools/globalTables');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
// OBTAIN
|
||||
@@ -241,6 +243,8 @@ async function myLoad() {
|
||||
|
||||
async function mystart() {
|
||||
|
||||
await estraiTutteLeImmagini();
|
||||
|
||||
if (process.env.PROD !== 1) {
|
||||
|
||||
testmsgwebpush();
|
||||
@@ -424,6 +428,104 @@ async function inizia() {
|
||||
// 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() {
|
||||
// console.log('Fai Test:')
|
||||
|
||||
|
||||
@@ -133,12 +133,12 @@ MsgBot = {
|
||||
'grazie😘'],
|
||||
PRINCIPE_AZZURRO: ['principe azzurro'],
|
||||
COSE_COVID: [
|
||||
'cos\'è il covid',
|
||||
'cosa è il covid',
|
||||
],
|
||||
'cos\'è il covid',
|
||||
'cosa è il covid',
|
||||
],
|
||||
COVID: [
|
||||
'covid',
|
||||
],
|
||||
'covid',
|
||||
],
|
||||
SPOSAMI: [
|
||||
'sposami',
|
||||
'vuoi sposar',
|
||||
@@ -149,7 +149,11 @@ MsgBot = {
|
||||
'mi sposi'],
|
||||
CHE_TEMPO_FA: ['che tempo'],
|
||||
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: [
|
||||
'stronz',
|
||||
'fanculo',
|
||||
@@ -242,6 +246,7 @@ const Menu = {
|
||||
MSG_TO_USER: 'sendmsgto',
|
||||
ADMIN: emoji.get('information_desk_person') + ' Admin',
|
||||
ALTRO: emoji.get('newspaper') + ' Altro',
|
||||
SETPICPROFILE: '🖼 SetPicProfile',
|
||||
// MSG_TO_NAVE: emoji.get('incoming_envelope') + 'Msg_to_Navi',
|
||||
// MSG_NO_7_REQ: emoji.get('incoming_envelope') + 'No 7 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. ' +
|
||||
'\nSono il tuo assistente virtuale (BOT).\n\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' +
|
||||
''+
|
||||
'' +
|
||||
'😍😍😍 Ora sei pronto per Entrare nella APP!\n' +
|
||||
'👉🏻 Clicca qui: %s',
|
||||
MSG_SET_USERNAME: '✨✨✨✨✨✨✨✨✨✨\n' +
|
||||
@@ -484,11 +489,12 @@ const txt = {
|
||||
'Ora puoi proseguire sulla APP.',
|
||||
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_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_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
|
||||
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 +
|
||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
@@ -514,7 +520,8 @@ const txt_es = {
|
||||
emo.EXCLAMATION_MARK +
|
||||
'\nComprueba en el sitio %s y reescribe el nuevo código de 6 dígitos.',
|
||||
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_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
|
||||
@@ -728,13 +735,16 @@ module.exports = {
|
||||
aportador = ` (${userdest})`;
|
||||
NameFrom += aportador;
|
||||
} 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 = '';
|
||||
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) {
|
||||
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp,
|
||||
userdest, true) + aportador;
|
||||
@@ -761,7 +771,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -803,7 +814,8 @@ module.exports = {
|
||||
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);
|
||||
|
||||
@@ -881,7 +893,6 @@ module.exports = {
|
||||
msg = cl.convertSpecialTags(rec.user, msg);
|
||||
}
|
||||
|
||||
|
||||
if (!!mydata.flotta) {
|
||||
// SOSTITUISCI LE PAROLE CHIAVI
|
||||
if (!!mydata.flotta.date_start)
|
||||
@@ -1013,7 +1024,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (!!idteleg) {
|
||||
strout += '\n (' + index + ') ' + user.username + ' (' + user.name + ' ' + user.surname + ':';
|
||||
strout += '\n (' + index + ') ' + user.username + ' (' +
|
||||
user.name + ' ' + user.surname + ':';
|
||||
if (mydata.inviareale) {
|
||||
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg,
|
||||
undefined, undefined, true);
|
||||
@@ -1208,20 +1220,22 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
setVerifiedReg: async function (idapp, lang, usernameorig, usernameDest) {
|
||||
setVerifiedReg: async function(idapp, lang, usernameorig, usernameDest) {
|
||||
try {
|
||||
await User.setVerifiedByAportador(idapp, usernameDest, true);
|
||||
await User.setFriendsCmd(idapp, usernameorig, usernameDest,
|
||||
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);
|
||||
}catch (e) {
|
||||
} catch (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);
|
||||
|
||||
@@ -1235,11 +1249,14 @@ module.exports = {
|
||||
|
||||
if (notask_verif) {
|
||||
// Non chiedi la verifica Registrazione
|
||||
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
|
||||
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest,
|
||||
myuser.username);
|
||||
} else {
|
||||
|
||||
const name = myuser.username + (myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '')
|
||||
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' + myuser.username;
|
||||
const name = myuser.username +
|
||||
(myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '');
|
||||
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' +
|
||||
myuser.username;
|
||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
|
||||
myuser.email);
|
||||
@@ -1264,7 +1281,8 @@ module.exports = {
|
||||
// Invia Msg
|
||||
if (domanda) {
|
||||
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) {
|
||||
@@ -1472,7 +1490,8 @@ class Telegram {
|
||||
msg = msg.replace('{username}', user.username);
|
||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||
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)
|
||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||
if (!!user.profile.revolut)
|
||||
@@ -1490,14 +1509,13 @@ class Telegram {
|
||||
// const cl = getclTelegByidapp(user.idapp);
|
||||
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
||||
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
async IsTesto(msg) {
|
||||
|
||||
let risp = '';
|
||||
@@ -1567,15 +1585,21 @@ class Telegram {
|
||||
|
||||
if (rec.status === Status.VERIFIED) {
|
||||
if (rec.user) {
|
||||
if (rec.user.profile.username_telegram && msg.from.id > 0 && !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 || '');
|
||||
if (rec.user.profile.username_telegram && msg.from.id > 0 &&
|
||||
!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 || '');
|
||||
}
|
||||
|
||||
if (!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 || '');
|
||||
this.sendMsg(msg.from.id, printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
|
||||
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 || '');
|
||||
this.sendMsg(msg.from.id,
|
||||
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
|
||||
} else {
|
||||
if (!rec.user.profile.username_telegram) {
|
||||
return this.checkIfUsernameTelegramSet(msg, rec.user);
|
||||
@@ -1677,8 +1701,10 @@ class Telegram {
|
||||
} else if (MsgBot.SEI_LIBERO.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Io? Sono per la Libertà! ' + emo.JOY +
|
||||
'\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
|
||||
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' + emo.DANCER + emo.FIRE;
|
||||
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find(
|
||||
(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)) {
|
||||
risp = 'Dipende ' + emo.SMILE_STAR + '\nProvaci!';
|
||||
} else if (MsgBot.DIVENTERO_RICCA.find(
|
||||
@@ -1687,7 +1713,8 @@ class Telegram {
|
||||
emo.GIFT_HEART;
|
||||
} else if (MsgBot.MA_ALLORA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
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';
|
||||
} else if (MsgBot.SEI_LIBERO_STASERA.find(
|
||||
(rec) => testo.indexOf(rec) > -1)) {
|
||||
@@ -1868,7 +1895,7 @@ class Telegram {
|
||||
await this.menumsgStaff(msg);
|
||||
} else if (testo === Menu.MSGPAOLO) {
|
||||
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);
|
||||
// } else if (testo === Menu.MSG_NO_9_REQ) {
|
||||
// await this.menumsg_No_9_Req(msg);
|
||||
@@ -1876,10 +1903,12 @@ class Telegram {
|
||||
// await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
|
||||
// } else if (cmd1 === Menu.MSG_TO_NAVE) {
|
||||
// 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);
|
||||
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||
await this.menumsg_A_Utente(msg);
|
||||
} else if (testo === Menu.SETPICPROFILE) {
|
||||
await this.setPhotoProfile(rec, msg);
|
||||
} else if (this.isSelMenu(msg, testo, 'INDIETRO') ||
|
||||
(testo === Menu.it.INDIETRO)) {
|
||||
await this.msgScegliMenu(msg);
|
||||
@@ -2298,7 +2327,7 @@ class Telegram {
|
||||
}
|
||||
|
||||
permitSendMsg(user) {
|
||||
return User.isAdmin(user.perm)
|
||||
return User.isAdmin(user.perm);
|
||||
}
|
||||
|
||||
async menumsgGenerico(msg, dest, username, extraparam) {
|
||||
@@ -2495,7 +2524,7 @@ class Telegram {
|
||||
|
||||
return true;
|
||||
}
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error('e');
|
||||
}
|
||||
}
|
||||
@@ -2521,7 +2550,9 @@ class Telegram {
|
||||
if (rec) {
|
||||
if (code === telegcode) {
|
||||
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) {}
|
||||
// let ris = await this.getUser(msg, rec, false);
|
||||
|
||||
@@ -2529,9 +2560,11 @@ class Telegram {
|
||||
await User.SetTelegramIdSuccess(this.idapp, user._id,
|
||||
msg.from.id).then((recuser) => {
|
||||
if (recuser) {
|
||||
let name = recuser.name;
|
||||
this.setPhotoProfile(rec, msg);
|
||||
let username = recuser.name;
|
||||
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);
|
||||
// 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
|
||||
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 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);
|
||||
|
||||
@@ -3075,8 +3110,7 @@ class Telegram {
|
||||
|| (isVerified && tools.isBitActive(rec.visibility,
|
||||
shared_consts.VISIB_ONLYIF_VERIFIED))
|
||||
|| (rec.visibility === 0))
|
||||
)
|
||||
{
|
||||
) {
|
||||
rec.active_mem = true;
|
||||
if (rec.main) {
|
||||
lang = rec.lang;
|
||||
@@ -3322,7 +3356,7 @@ class Telegram {
|
||||
return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
|
||||
ripr_menuPrec);
|
||||
}
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error('Error sendMsg', e);
|
||||
}
|
||||
|
||||
@@ -3340,6 +3374,43 @@ class Telegram {
|
||||
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) {
|
||||
let mykeyb = {
|
||||
parse_mode: 'HTML',
|
||||
@@ -3577,16 +3648,20 @@ if (true) {
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||
data.username,
|
||||
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) {
|
||||
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(
|
||||
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`);
|
||||
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${user.username}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username,
|
||||
msgOrig);
|
||||
@@ -3594,8 +3669,10 @@ if (true) {
|
||||
msgDest);
|
||||
}
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||
data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
|
||||
if (changed) {
|
||||
|
||||
@@ -25,6 +25,7 @@ const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const server_constants = require('./server_constants');
|
||||
|
||||
const download = require('image-downloader');
|
||||
|
||||
// SETTINGS WebPush Configuration
|
||||
const webpush = require('web-push');
|
||||
@@ -880,7 +881,8 @@ module.exports = {
|
||||
let actions = [];
|
||||
if (cmd) {
|
||||
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;
|
||||
tag = 'reqgroups';
|
||||
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
|
||||
@@ -1096,17 +1098,25 @@ module.exports = {
|
||||
return myapp.abilitanave;
|
||||
},
|
||||
|
||||
getdirByIdApp: function(idapp) {
|
||||
getdirByIdApp: function(idapp, dirmain = false) {
|
||||
|
||||
let mypath = '';
|
||||
const myapp =
|
||||
this.getApps().find(item => item.idapp === idapp);
|
||||
if (myapp) {
|
||||
if (process.env.NODE_ENV === 'test')
|
||||
return (myapp) ? myapp.dir_test : '';
|
||||
mypath = (myapp) ? myapp.dir_test : '';
|
||||
else
|
||||
return (myapp) ? myapp.dir : '';
|
||||
} else
|
||||
return '';
|
||||
mypath = (myapp) ? myapp.dir : '';
|
||||
|
||||
if (dirmain) {
|
||||
if (this.sulServer() !== 1) {
|
||||
mypath += '/public';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mypath;
|
||||
},
|
||||
|
||||
getAdminEmailByIdApp: function(idapp) {
|
||||
@@ -1137,7 +1147,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
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) {
|
||||
@@ -1177,7 +1188,7 @@ module.exports = {
|
||||
return (myapp && myapp.telegram_support_chat)
|
||||
? myapp.telegram_support_chat
|
||||
: '';
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
@@ -2118,7 +2129,7 @@ module.exports = {
|
||||
const stream = fs.createWriteStream(filename, {flags: 'a'});
|
||||
stream.write('\n' + mystr);
|
||||
stream.end();
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -2180,7 +2191,10 @@ module.exports = {
|
||||
callback(err);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
console.log(' ... File Rinominato', oldPath, 'in:', newPath);
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
|
||||
@@ -2192,6 +2206,7 @@ module.exports = {
|
||||
writeStream.on('error', callback);
|
||||
|
||||
readStream.on('close', function() {
|
||||
console.log('cancella file già copiato', oldPath);
|
||||
fs.unlink(oldPath, callback);
|
||||
});
|
||||
|
||||
@@ -2222,8 +2237,13 @@ module.exports = {
|
||||
try {
|
||||
let img_small = path.dirname(mypath) + '/' +
|
||||
server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
||||
fs.unlink(img_small, () => {});
|
||||
console.log('delete file', mypath);
|
||||
fs.unlink(img_small, function(err) {
|
||||
if (err)
|
||||
console.log('Errore durante la Cancellazione del file', mypath);
|
||||
else
|
||||
console.log('deleted file', mypath);
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -2574,7 +2594,7 @@ module.exports = {
|
||||
return process.env.LOCALE !== '1';
|
||||
},
|
||||
|
||||
refreshAllTablesInMem(idapp, table){
|
||||
refreshAllTablesInMem(idapp, table) {
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
if (table === shared_consts.TAB_MYBOTS) {
|
||||
@@ -2583,6 +2603,15 @@ module.exports = {
|
||||
telegrambot.reloadSites();
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
downloadImage(url, filepath) {
|
||||
|
||||
return download.image({
|
||||
url,
|
||||
dest: filepath
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -4663,6 +4663,11 @@ ignore-walk@^3.0.1:
|
||||
dependencies:
|
||||
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:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.6.1.tgz#98122a562d59dcc097ef1b2c8191866eb8f5d663"
|
||||
|
||||
Reference in New Issue
Block a user