Aggiunto messaggio nella registrazione, dicendo che occorre avere Telegram installato.

PASSARE TUTTI I _DOC e mettergli .lean() prima dello then()  -> velocizza le Query di Mongodb
"Floriterapia
costellazioni familiari
coach motivazionale
Tecniche Essene"
Inserimento Gruppi: anche il comune obbligatorio
Far comparire le ultime persone registrate
Mettere il controllo dell'abilitazione del BOT Telegram solo dopo che conosco il suo username, e cosi gli metto anche il contatto telegram.
risolto foto profilo di telegram che non si salvava in automatico
tolto il controllo della email
aggiunto msg se errore al server, installare altro browser.
This commit is contained in:
paoloar77
2022-03-03 20:32:04 +01:00
parent 94a2a073e5
commit c1cecc5eb4
11 changed files with 228 additions and 169 deletions

View File

@@ -40,11 +40,11 @@ html
- var index = 0
each product in orders.items
- var descr = product._doc.order.product.name
- var img = product._doc.order.product.img
- var price = product._doc.order.price
- var after_price = product._doc.order.after_price
- var qty = product._doc.order.quantity
- var descr = product.order.product.name
- var img = product.order.product.img
- var price = product.order.price
- var after_price = product.order.after_price
- var qty = product.order.quantity
- index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")

View File

@@ -40,11 +40,11 @@ html
- var index = 0
each product in orders.items
- var descr = product._doc.order.product.name
- var img = product._doc.order.product.img
- var price = product._doc.order.price
- var after_price = product._doc.order.after_price
- var qty = product._doc.order.quantity
- var descr = product.order.product.name
- var img = product.order.product.img
- var price = product.order.price
- var after_price = product.order.after_price
- var qty = product.order.quantity
- index = index + 1
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")

View File

@@ -1,5 +1,4 @@
const mongoose = require('mongoose').set('debug', false)
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
const shared_consts = require('../tools/shared_nodejs');
@@ -8,25 +7,25 @@ const Order = require('../models/order');
const CartSchema = new Schema({
idapp: {
type: String
type: String,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
totalQty: {type: Number, default: 0},
totalPrice: {type: Number, default: 0},
department: {
type: String, ref: 'Department'
type: String, ref: 'Department',
},
items: [
{
order:
{ type: Schema.Types.ObjectId, ref: 'Order' }
}
{type: Schema.Types.ObjectId, ref: 'Order'},
},
],
note: {
type: String
type: String,
},
modify_at: {
type: Date
type: Date,
},
});
@@ -35,13 +34,12 @@ var Cart = module.exports = mongoose.model('Cart', CartSchema);
module.exports.findAllIdApp = async function(idapp, userId) {
const myfind = {idapp, userId};
return await Cart.findOne(myfind);
return await Cart.findOne(myfind).lean();
};
module.exports.getCartByUserId = async function(uid, idapp) {
let query = { userId: uid, idapp }
const mycart = await Cart.findOne(query);
let query = {userId: uid, idapp};
const mycart = await Cart.findOne(query).lean();
if (!!mycart) {
for (const idkey in mycart.items) {
@@ -53,7 +51,7 @@ module.exports.getCartByUserId = async function (uid, idapp) {
}
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
mycart.items[idkey]._doc.order = myord[0];
mycart.items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
@@ -63,12 +61,12 @@ module.exports.getCartByUserId = async function (uid, idapp) {
}
return null;
}
};
module.exports.updateCartByUserId = function(userId, newCart, callback) {
let query = { userId: userId }
let query = {userId: userId};
Cart.find(query, function(err, c) {
if (err) throw err
if (err) throw err;
//exist cart in databse
if (c.length > 0) {
@@ -79,50 +77,48 @@ module.exports.updateCartByUserId = function (userId, newCart, callback) {
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId
}
userId: userId,
},
},
{new: true},
callback
)
callback,
);
} else {
//no cart in database
newCart.save(callback)
}
})
newCart.save(callback);
}
});
};
module.exports.updateCartByCartId = async function(cartId, newCart) {
// delete newCart._doc._id;
const items = newCart._doc.items;
const items = newCart.items;
const totalQty = newCart.totalQty;
const totalPrice = newCart.totalPrice;
const modify_at = new Date();
return await Cart.findOneAndUpdate({ _id: cartId }, {
return Cart.findOneAndUpdate({_id: cartId}, {
$set: {
items,
totalPrice,
totalQty,
modify_at
}
}, { new: false })
.then((ris) => {
modify_at,
},
}, {new: false}).lean().then((ris) => {
return ris;
}).catch(err => {
console.log('err', err);
return null
})
return null;
});
}
};
module.exports.deleteCartByCartId = async function(cartId) {
return await Cart.remove({_id: cartId});
}
};
module.exports.createCart = async function(newCart) {
return await newCart.save()
}
return await newCart.save();
};

View File

@@ -160,8 +160,8 @@ NewstosentSchema.statics.isActivated = async function (_id) {
const Newstosent = this;
try {
const mydoc = await Newstosent.findOne({ _id });
return (mydoc._doc.activate);
const mydoc = await Newstosent.findOne({ _id }).lean();
return (mydoc.activate);
} catch (e) {
return false
}

View File

@@ -109,7 +109,7 @@ module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
query.userId = uid;
}
myorderscart = await OrdersCart.find(query);
myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
@@ -119,10 +119,10 @@ module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
@@ -154,7 +154,7 @@ module.exports.getOrdersCartByUserId = async function (uid, idapp, numorder) {
module.exports.getOrdersCartByDepartmentId = async function (depId, idapp) {
let query = { idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
const myorderscart = await OrdersCart.find(query);
const myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
@@ -164,10 +164,10 @@ module.exports.getOrdersCartByDepartmentId = async function (depId, idapp) {
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
@@ -181,7 +181,7 @@ module.exports.getOrdersCartByDepartmentId = async function (depId, idapp) {
module.exports.getOrderById = async function (Id, idapp) {
let query = { _id: Id, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_SENT } }
const myorderscart = await OrdersCart.find(query);
const myorderscart = await OrdersCart.find(query).lean();
for (let ind = 0; ind < myorderscart.length; ind++) {
for (const idkey in myorderscart[ind].items) {
@@ -191,10 +191,10 @@ module.exports.getOrderById = async function (Id, idapp) {
if (!!myorder) {
idorder = myorderscart[ind].items[idkey].order._id.toString();
}
myorderscart[ind]._doc.nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
myorderscart[ind].nameSurname = await User.getNameSurnameById(idapp, myorderscart[ind].userId);
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
myorderscart[ind].items[idkey]._doc.order = myord[0];
myorderscart[ind].items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);

View File

@@ -4,6 +4,7 @@ const validator = require('validator');
const jwt = require('jsonwebtoken');
const _ = require('lodash');
const tools = require('../tools/general');
const {Settings} = require('../models/settings');
@@ -996,7 +997,7 @@ UserSchema.statics.getindOrderDuplicate = function(idapp) {
return User.aggregate(User.getUsersNationalityQuery(idapp)).then(ris => {
// console.table(ris);
return JSON.stringify(ris);
return ris;
});
};
@@ -1875,7 +1876,7 @@ UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
return User.find({
idapp, 'profile.teleg_id': teleg_id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).then((rec) => {
}).lean().then((rec) => {
return (!!rec) ? rec._doc : null;
}).catch((e) => {
console.error('UserExistByIdTelegram', e);
@@ -1891,7 +1892,7 @@ UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
return User.findOneAndUpdate({
idapp, username,
}, {$set: fields_to_update}, {new: false}).then((record) => {
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
return !!record;
});
@@ -1903,7 +1904,7 @@ UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
return User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {'profile.teleg_id': 1}).then((rec) => {
}, {'profile.teleg_id': 1}).lean().then((rec) => {
return (!!rec) ? rec.profile.teleg_id : null;
}).catch((e) => {
console.error('TelegIdByUsername', e);
@@ -1914,7 +1915,7 @@ UserSchema.statics.notAsk_VerifByUsername = async function(idapp, username) {
return User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {'notask_verif': 1}).then((rec) => {
}, {'notask_verif': 1}).lean().then((rec) => {
return (!!rec && rec.notask_verif) ? true: false;
}).catch((e) => {
console.error('notAsk_VerifByUsername', e);
@@ -1932,7 +1933,7 @@ UserSchema.statics.SetTelegramCheckCode = async function(
return User.findOneAndUpdate({
_id: id,
}, {$set: fields_to_update}, {new: false}).then((record) => {
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
return !!record;
});
@@ -1966,7 +1967,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
return User.findOneAndUpdate({
idapp,
_id: id,
}, {$set: fields_to_update}, {new: false}).then((record) => {
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
return record;
});
@@ -2690,8 +2691,8 @@ UserSchema.statics.checkUser = async function(idapp, username) {
notask_verif: 1,
'profile.teleg_id': 1,
'profile.teleg_checkcode': 1,
}).then((rec) => {
return JSON.stringify(rec);
}).lean().then((rec) => {
return rec;
});
};
@@ -2720,7 +2721,18 @@ UserSchema.statics.calculateStat = async function(idapp, username) {
const numGroups = await MyGroup.countDocuments({idapp});
return {numMySkills, numMyGoods, numMyBachecas, numUsersReg, numGroups};
let numByTab = {}
const globalTables = require('../tools/globalTables');
for (let table of shared_consts.TABLES_VISU_STAT_IN_HOME) {
let mytable = globalTables.getTableByTableName(table);
if (mytable) {
numByTab[table] = await mytable.countDocuments({idapp});
}
}
return {numByTab, numUsersReg};
} catch (e) {
console.error(e.message);
}
@@ -2752,7 +2764,7 @@ UserSchema.statics.findAllDistinctNationality = async function(idapp) {
return User.aggregate(User.getDistinctNationalityQuery(idapp)).then(ris => {
// console.table(ris);
return JSON.stringify(ris);
return ris;
});
};
@@ -2863,7 +2875,7 @@ UserSchema.statics.calcRegDaily = async function(idapp) {
return User.aggregate(User.getUsersRegDaily(idapp, 30)).then(ris => {
// console.table(ris);
return JSON.stringify(ris);
return ris;
});
};
@@ -2872,7 +2884,7 @@ UserSchema.statics.calcRegWeekly = async function(idapp) {
return User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
// console.table(ris);
return JSON.stringify(ris.slice(0, -1));
return ris.slice(0, -1);
});
};
@@ -3160,9 +3172,9 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
}, {username: 1});
}, {username: 1}).lean();
recUser._doc.profile.asked_friends = listSentMyRequestFriends
recUser.profile.asked_friends = listSentMyRequestFriends
? listSentMyRequestFriends
: [];
@@ -3176,7 +3188,7 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
{deleted: {$exists: true, $eq: false}}],
}, MyGroup.getWhatToShow_Unknown());
recUser._doc.profile.asked_groups = listSentMyRequestGroups
recUser.profile.asked_groups = listSentMyRequestGroups
? listSentMyRequestGroups
: [];
@@ -3190,7 +3202,7 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
{deleted: {$exists: true, $eq: false}}],
});
recUser._doc.profile.manage_mygroups = listManageGroups
recUser.profile.manage_mygroups = listManageGroups
? listManageGroups
: [];

View File

@@ -110,5 +110,9 @@ module.exports = {
{_id: 108, idSector: [10], descr: 'Affrancamento'},
{_id: 109, idSector: [10], descr: 'Supporto'},
{_id: 110, idSector: [10], descr: 'Consulenza'},
{_id: 111, idSector: [6], descr: 'Floriterapia'},
{_id: 112, idSector: [6], descr: 'Costellazioni Familiari'},
{_id: 113, idSector: [6], descr: 'Coach Motivazionale'},
{_id: 114, idSector: [6], descr: 'Tecniche Essene'},
],
};

View File

@@ -558,7 +558,7 @@ async function faitest() {
const langdest = 'it';
telegrambot.askConfirmationUserRegistration(myuser.idapp,
shared_consts.CallFunz.REGISTRATION, myuser, 'perseo77', langdest);
shared_consts.CallFunz.REGISTRATION, myuser);
}

View File

@@ -198,6 +198,7 @@ MsgBot = {
DONNA: ['donna', 'femmina'],
FARE_DOMANDA: ['fare una domanda', 'posso farti una domanda'],
DIVENTERO_RICCA: ['diventerò ricc'],
DOVE_VUOI_VIVERE: ['dove vuoi vivere'],
MA_ALLORA: ['ma allora'],
};
@@ -772,12 +773,6 @@ module.exports = {
addtext + text, false, null, userdest);
}
if (phase === this.phase.REGISTRATION) {
await this.askConfirmationUserRegistration(mylocalsconf.idapp,
shared_consts.CallFunz.REGISTRATION,
mylocalsconf.user, userdest, langdest);
}
/*
// Invia richiesta allo Sponsor
const domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
@@ -1236,62 +1231,6 @@ module.exports = {
}
},
askConfirmationUserRegistration: async function(
idapp, myfunc, myuser, userDest = '', langdest = '') {
const cl = getclTelegByidapp(idapp);
try {
let keyb = null;
let domanda = '';
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
if (notask_verif) {
// Non chiedi la verifica Registrazione
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;
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
myuser.email);
keyb = cl.getInlineKeyboard(myuser.lang, [
{
text: '✅ Abilita ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
{
text: '🚫 Rifiuta ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
]);
}
}
// Invia Msg
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
undefined, undefined, true, keyb);
}
} catch (e) {
console.error('Error askConfirmationUserRegistration', e);
}
},
};
@@ -1328,6 +1267,69 @@ async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
}
async function askConfirmationUserRegistration(idapp, myfunc, myuser, usernametelegram = '', name_telegram = '', surname_telegram = '') {
const cl = getclTelegByidapp(idapp);
try {
const userDest = myuser.aportador_solidario;
const langdest = myuser.lang;
let keyb = null;
let domanda = '';
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
if (notask_verif) {
// Non chiedi la verifica Registrazione
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;
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
`<br>Username: <b>${name}</b><br>Profilo su APP: ${linkuserprof}<br>Email: ` +
myuser.email);
if (usernametelegram) {
domanda += '<br>Profilo su Telegram [' + name_telegram + ' ' + surname_telegram + ']:<br>' + 'https://t.me/' + usernametelegram;
}
keyb = cl.getInlineKeyboard(myuser.lang, [
{
text: '✅ Abilita ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
{
text: '🚫 Rifiuta ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
]);
}
}
// Invia Msg
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda,
undefined, undefined, true, keyb);
}
} catch (e) {
console.error('Error askConfirmationUserRegistration', e);
}
}
function getusernameByUser(idapp, msg) {
let username = '';
let rec = this.getRecInMem(msg);
@@ -1381,6 +1383,24 @@ async function local_sendMsgTelegram(idapp, username, text) {
}
async function local_sendMsgTelegramByIdTelegram(idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
MyForm = null) {
console.log('sendMsgTelegramByIdTelegram', text);
if (!idtelegram)
return;
const cl = getclTelegByidapp(idapp);
if (cl && idtelegram) {
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
chat_id, ripr_menuPrec);
}
}
function getstr(lang, key, param1) {
let mystr = '';
@@ -1598,6 +1618,14 @@ class Telegram {
msg.from.last_name || '');
await this.sendMsg(msg.from.id,
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
if (!rec.user.verified_by_aportador) {
askConfirmationUserRegistration(this.idapp,
shared_consts.CallFunz.REGISTRATION, rec.user,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
}
} else {
if (!rec.user.profile.username_telegram) {
return this.checkIfUsernameTelegramSet(msg, rec.user);
@@ -1711,8 +1739,9 @@ 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.DOVE_VUOI_VIVERE.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'Mah a me piacerebbe vivere al mare, ma anche vicino al verde, in montagna. Sarebbe l\'ideale 😄';
} 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)) {
@@ -2568,9 +2597,15 @@ class Telegram {
if (recuser) {
this.setPhotoProfile(rec, msg);
let username = recuser.name;
this.sendMsg(msg.from.id,
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), username, tools.getHostByIdApp(this.idapp)));
if (msg.from.username) {
askConfirmationUserRegistration(this.idapp,
shared_consts.CallFunz.REGISTRATION, recuser,msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
}
this.checkIfUsernameTelegramSet(msg, recuser);
// local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
} else {
@@ -3098,9 +3133,12 @@ class Telegram {
if (recuser) {
if (!(recuser.menuSaved[idapp]))
load = true;
if (recuser.menuDb || recuser.pageChange)
load = true;
}
}
if (load || !recuser.menuDb || recuser.pageChange) {
if (load) {
// Check if you are Admin
const user = await User.UserByIdTelegram(idapp, id);
@@ -3154,7 +3192,7 @@ class Telegram {
recuser.pageChange = false;
recuser.menuSaved[idapp] = arrlang;
}
return recuser.menuSaved[idapp];
return recuser ? recuser.menuSaved[idapp] : null;
} catch (e) {
console.log('Err loadMenuFromDb: ' + e);
}
@@ -3205,7 +3243,7 @@ class Telegram {
return '';
} else if (recdb.type === shared_consts.BOTTYPE_MENU) {
if (recdb.value) {
this.isMenu(rec, msg, recdb.value, true);
this.isMenu(recuser, msg, recdb.value, true);
return shared_consts.RIS_OK;
}
}
@@ -3411,18 +3449,24 @@ class Telegram {
const file_path = result.file_path;
const photo_url = 'https://api.telegram.org/file/bot' + token + '/' + file_path;
console.log('photo_url', photo_url);
console.log('1) photo_url', photo_url);
let filename = tools.extractFileName(photo_url);
myfileprofile += filename;
console.log('myfileprofile', myfileprofile);
const pathfile = tools.extractFilePath(myfileprofile);
tools.mkdirpath(pathfile);
console.log('2) myfileprofile', pathfile);
return tools.downloadImage(photo_url, myfileprofile).
then((ris) => {
console.log('setPicProfile ris', ris);
console.log('3) setPicProfile ris', ris);
return User.setPicProfile(idapp, username, filename).then((ris) => {
console.log('sendMsg picprofile Copied !');
console.log('4) sendMsg picprofile Copied !');
local_sendMsgTelegram(idapp, username, printf(getstr(lang, 'MSG_SET_PICPROFILE'), editprofile));
});
// console.log('scaricato');
}).catch((err) => {
console.error('Error setPhotoProfile', err);
});
});

View File

@@ -2626,6 +2626,7 @@ module.exports = {
dest: filepath
});
}catch (e) {
console.error('Err download image', e);
return false;
}

View File

@@ -96,6 +96,8 @@ module.exports = {
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups'],
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'mygoods', 'mygroups'],
TABLES_ID_NUMBER: [
'permissions',
'levels',