diff --git a/src/server/models/mygood.js b/src/server/models/mygood.js
index 7f56976..82387de 100755
--- a/src/server/models/mygood.js
+++ b/src/server/models/mygood.js
@@ -49,6 +49,9 @@ const MyGoodSchema = new Schema({
adType: {
type: Number,
},
+ otherfilters: [{
+ type: Number,
+ }],
photos: [
{
imagefile: {
@@ -149,6 +152,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
idCity: 1,
numLevel: 1,
adType: 1,
+ otherfilters: 1,
photos: 1,
note: 1,
website: 1,
@@ -236,6 +240,7 @@ MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) {
'idCity': 1,
'numLevel': 1,
adType: 1,
+ otherfilters: 1,
'photos': 1,
note: 1,
website: 1,
@@ -288,6 +293,7 @@ MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) {
'idCity': 1,
'numLevel': 1,
adType: 1,
+ otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
@@ -340,6 +346,7 @@ MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) {
'idCity': 1,
'numLevel': 1,
adType: 1,
+ otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
@@ -392,6 +399,7 @@ MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) {
'idCity': 1,
'numLevel': 1,
adType: 1,
+ otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
@@ -444,6 +452,7 @@ MyGoodSchema.statics.getMyGoodById = function(idapp, idGood) {
'idCity': 1,
'numLevel': 1,
adType: 1,
+ otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
diff --git a/src/server/models/site.js b/src/server/models/site.js
index 993baa9..03b6548 100755
--- a/src/server/models/site.js
+++ b/src/server/models/site.js
@@ -65,6 +65,9 @@ const SiteSchema = new Schema({
telegram_bot_name_test: {
type: String,
},
+ telegram_support_chat: {
+ type: String,
+ },
pathreg_add: {
type: String,
},
diff --git a/src/server/models/user.js b/src/server/models/user.js
index 419d405..2fad1b2 100755
--- a/src/server/models/user.js
+++ b/src/server/models/user.js
@@ -598,6 +598,8 @@ UserSchema.statics.findByUsername = async function(idapp, username, alsoemail) {
const myreg = ['^', username, '$'].join('');
let regexusername = new RegExp(myreg, 'i');
+ //++TODO: Set only the necessary fields to get in memory
+
return User.findOne({
idapp: idapp,
username: {$regex: regexusername},
diff --git a/src/server/populate/cities.js b/src/server/populate/cities.js
index c11fa90..82a161d 100644
--- a/src/server/populate/cities.js
+++ b/src/server/populate/cities.js
@@ -1,16 +1,5 @@
module.exports = {
list: [
- {
- _id: 1,
- istat: 'Istat',
- comune: 'Comune',
- prov: 'Provincia',
- reg: 'Regione',
- pref: 'Prefisso',
- cap: 'CAP',
- abitanti: 'CodFisco',
- country: 'IT',
- },
{
_id: 2,
istat: '028001',
diff --git a/src/server/populate/goods.js b/src/server/populate/goods.js
index 4037e9d..0b8ec21 100644
--- a/src/server/populate/goods.js
+++ b/src/server/populate/goods.js
@@ -18,7 +18,7 @@ module.exports = {
{_id: 16, idSectorGood: [3], descr: 'Van (furgoni camperizzati)'},
{_id: 17, idSectorGood: [4], descr: 'Bigiotteria'},
{_id: 18, idSectorGood: [4], descr: 'Lavoretti'},
- {_id: 19, idSectorGood: [4], descr: 'Mangia e bevi'},
+ {_id: 19, idSectorGood: [4], descr: 'Altro'},
{_id: 20, idSectorGood: [5], descr: 'Accessori bellezza'},
{_id: 21, idSectorGood: [5], descr: 'Creme e detergenti'},
{_id: 22, idSectorGood: [5], descr: 'Trucchi e profumi'},
diff --git a/src/server/populate/sectorgoods.js b/src/server/populate/sectorgoods.js
index 9727df7..bf28bb4 100644
--- a/src/server/populate/sectorgoods.js
+++ b/src/server/populate/sectorgoods.js
@@ -3,7 +3,7 @@ module.exports = {
{_id: 1, descr: 'Abbigliamento'},
{_id: 2, descr: 'Arredamento'},
{_id: 3, descr: 'Auto e Moto'},
- {_id: 4, descr: 'Autoproduzione'},
+ {_id: 4, descr: 'Artigianato'},
{_id: 5, descr: 'Bellezza e Igiene'},
{_id: 6, descr: 'Bimbi'},
{_id: 7, descr: 'Cibo'},
diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js
index fb1381d..5644470 100755
--- a/src/server/router/users_router.js
+++ b/src/server/router/users_router.js
@@ -955,7 +955,7 @@ async function eseguiDbOp(idapp, mydata, locale) {
// Svuota e Ricrea
- const {City} = require('../modWels/city');
+ const {City} = require('../models/city');
const {Province} = require('../models/province');
await City.deleteMany({});
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index e54d737..05f145d 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -458,8 +458,27 @@ const txt = {
MSG_ERR_VERIFY_CODE: 'Codice di Verifica Errato!' + emo.EXCLAMATION_MARK +
'\nControlla sul sito %s e riscrivi il nuovo codice di 6 cifre.',
MSG_VERIFY_OK: emoji.get('grinning') +
- ' Benvenuto %s! Ti sei correttamente verificato con il BOT. ' +
- '\nSono il tuo assistente virtuale.\n',
+ ' β
π Benvenuto %s!\n' +
+ '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!',
+ MSG_SET_USERNAME: 'β¨β¨β¨β¨β¨β¨β¨β¨β¨β¨\n' +
+ 'π Devi impostare un Username per Telegram:\n' +
+ '\n' +
+ 'ππ» 1. Premi sull\'icona (tre linee orizzontali) del menu principale in alto a sinistra.\n' +
+ 'ππ» 2. Seleziona la voce Impostazioni nel menu.\n' +
+ 'ππ» 3.Premi su Username nella sezione account.\n' +
+ 'ππ» 4. Digita il tuo username. Deve essere un nome ancora libero e non giΓ usato da altri.\n' +
+ 'ππ» 5. Per confermare premi sull\'icona con la spunta in alto a destra.\n' +
+ 'π Infine scrivi OK su questa chat. \n\n' +
+ 'π¬ In questo modo le persone potranno contattarti dalla APP cliccando sull\'icona di Telegram, presente nel tuo profilo.',
+ MSG_SET_USERNAME_OK: 'ππβ
β
Ottimo! Hai impostato lo Username Telegram!\n\n' +
+ 'Ora le persone potranno contattarti su Telegram, anche dalla APP visitando il tuo profilo e cliccando sull\'icona di Telegram, (senza dover pubblicare il proprio numero di cellulare).\n\n' +
+ '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',
@@ -1413,6 +1432,12 @@ class Telegram {
return tools.getHostByIdApp(this.idapp) + '/faq';
}
+ getstrChatHelp() {
+ return 'Clicca qui per entrare nella Chat HELP di Supporto\n' +
+ tools.getTelegramSupportChat(this.idapp) +
+ '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
+ }
+
async IsTesto(msg) {
let risp = '';
@@ -1480,6 +1505,25 @@ class Telegram {
const menusite = await this.isMenuSite(this.idapp, testo, lang, id);
+ 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.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')));
+ } else {
+ if (!rec.user.profile.username_telegram) {
+ return this.checkIfUsernameTelegramSet(msg, rec.user);
+ }
+ }
+ }
+ }
+
if (risp === '') {
if (menusite) {
risp = this.getValueMenu(this.idapp, testo, lang);
@@ -1561,9 +1605,7 @@ class Telegram {
'il piΓΉ grande esperimento dell\'Uomo di ipnosi di massa, riempiendo di bugie i media mondiali, che servono sostanzialmente a controllare i popoli.' +
'E con questo ti ho detto tutto. :D ';
} else if (MsgBot.AIUTO.find((rec) => testo.indexOf(rec) > -1)) {
- risp = 'Clicca qui per entrare nella Chat HELP di Supporto\n' +
- tools.HELP_CHAT +
- '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
+ risp = this.getstrChatHelp();
} else if (MsgBot.SPOSAMI.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'No Grazie! Sono per la LibertΓ a Vita! ' + emo.JOY +
'\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
@@ -2375,6 +2417,20 @@ class Telegram {
}
}
+ checkIfUsernameTelegramSet(msg, recuser) {
+ try {
+ if (!msg.from.username) {
+ //
+ this.sendMsg(msg.from.id,
+ printf(getstr(recuser.lang, 'MSG_SET_USERNAME')));
+
+ return true;
+ }
+ }catch (e) {
+ console.error('e');
+ }
+ }
+
async setVerifyCode(msg) {
try {
if (!!msg.text) {
@@ -2407,6 +2463,8 @@ class Telegram {
let name = recuser.name;
this.sendMsg(msg.from.id,
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), 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 {
this.sendMsg(msg.from.id,
@@ -2788,8 +2846,7 @@ class Telegram {
await this.isMenu(rec, msg);
}
} else {
- await
- this.isMenuNotVerified(rec, msg);
+ await this.isMenuNotVerified(rec, msg);
}
}
@@ -3170,16 +3227,20 @@ class Telegram {
async sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec) {
- if (text.length > 4090) {
- let text1 = text.slice(0, 4090);
- let text2 = text.slice(4090, text.length);
- await this._inviaMsg(id, text1, form, menu, msg_id, chat_id,
- ripr_menuPrec);
- return await this._inviaMsg(id, text2, form, menu, msg_id, chat_id,
- ripr_menuPrec);
- } else {
- return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
- ripr_menuPrec);
+ try {
+ if (text.length > 4090) {
+ let text1 = text.slice(0, 4090);
+ let text2 = text.slice(4090, text.length);
+ await this._inviaMsg(id, text1, form, menu, msg_id, chat_id,
+ ripr_menuPrec);
+ return await this._inviaMsg(id, text2, form, menu, msg_id, chat_id,
+ ripr_menuPrec);
+ } else {
+ return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
+ ripr_menuPrec);
+ }
+ }catch (e) {
+ console.error('Error sendMsg', e);
}
}
@@ -3317,6 +3378,7 @@ if (true) {
try {
const token = tools.getTelegramKeyByIdApp(idapp);
const nomebot = tools.getTelegramBotNameByIdApp(idapp);
+
// console.log('idapp', idapp, 'token', token);
if (!!token) {
diff --git a/src/server/tools/general.js b/src/server/tools/general.js
index 66a8bd2..478d3ac 100755
--- a/src/server/tools/general.js
+++ b/src/server/tools/general.js
@@ -1146,6 +1146,17 @@ module.exports = {
return (myapp) ? myapp.telegram_bot_name : '';
},
+ getTelegramSupportChat: function(idapp) {
+ try {
+ const myapp = this.getApps().find((item) => item.idapp === idapp);
+ return (myapp && myapp.telegram_support_chat)
+ ? myapp.telegram_support_chat
+ : '';
+ }catch (e) {
+ return '';
+ }
+ },
+
getTelegramKeyByIdApp: function(idapp) {
const myarr = this.getApps();
const myapp = myarr.find((item) => item.idapp === idapp);