diff --git a/src/server/models/user.js b/src/server/models/user.js
index cf07f44..8827c73 100755
--- a/src/server/models/user.js
+++ b/src/server/models/user.js
@@ -668,6 +668,8 @@ UserSchema.statics.getUserShortDataByUsername = async function(idapp, username)
verified_by_aportador: 1,
'profile.teleg_id': 1,
'profile.username_telegram': 1,
+ 'profile.firstname_telegram': 1,
+ 'profile.lastname_telegram': 1,
// 'profile.saw_zoom_presentation': 1,
'profile.ask_zoom_partecipato': 1,
'profile.qualified': 1,
@@ -1347,6 +1349,8 @@ UserSchema.statics.getUserProfileByUsername = async function(
'profile.biografia': 1,
'profile.teleg_id': 1,
'profile.username_telegram': 1,
+ 'profile.firstname_telegram': 1,
+ 'profile.lastname_telegram': 1,
'profile.intcode_cell': 1,
'profile.cell': 1,
'profile.website': 1,
@@ -1378,6 +1382,8 @@ UserSchema.statics.getUserProfileByUsername = async function(
'profile.biografia': 1,
'profile.teleg_id': 1,
'profile.username_telegram': 1,
+ 'profile.firstname_telegram': 1,
+ 'profile.lastname_telegram': 1,
'profile.intcode_cell': 1,
'profile.cell': 1,
'profile.website': 1,
@@ -1544,7 +1550,7 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
'profile.friends': {
$elemMatch: {username: {$eq: usernameDest}},
},
- });
+ }, {_id: 1}).lean();
if (!foundIfAlreadyFriend) {
update = {
@@ -1568,7 +1574,7 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
'profile.friends': {
$elemMatch: {username: {$eq: usernameOrig}},
},
- });
+ }, {_id: 1}).lean();
if (!foundIfAlreadyFriend2) {
update = {
@@ -1582,10 +1588,11 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
ris = await User.updateOne({idapp, username: usernameDest}, update);
this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
+ this.removeReqFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da te
}
- if (ris) {
- ris = await User.getInfoFriendByUsername(idapp, usernameDest);
- }
+ //if (ris) {
+ ris = await User.getInfoFriendByUsername(idapp, usernameDest);
+ //}
} else if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
// Aggiungo la richiesta di Amicizia a me
const foundIfAlreadyAskFriend = await User.findOne({
@@ -1594,7 +1601,7 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
'profile.req_friends': {
$elemMatch: {username: {$eq: usernameOrig}},
},
- });
+ }, {_id: 1}).lean();
if (value) {
if (!foundIfAlreadyAskFriend) {
@@ -1610,21 +1617,24 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
}
if (ris) {
// Invia una notifica alla persona
- tools.sendNotificationByUsername(idapp, usernameDest, cmd, true,
- usernameOrig);
+ tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
}
} else {
if (foundIfAlreadyAskFriend) {
- ris = await this.removeFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
+ ris = await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
}
}
- if (ris) {
- ris = await User.getInfoAskFriendByUsername(idapp, usernameDest);
- }
+ // if (ris) {
+ ris = await User.getInfoAskFriendByUsername(idapp, usernameDest);
+ // }
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) {
+ // Rimuovi anche le eventuali richieste di Amicizia !
+ await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
+ await this.removeReqFriend(idapp, usernameOrig, usernameDest); // Rimuovo la Richiesta di Amicizia da me
+
await this.removeFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
@@ -1635,6 +1645,9 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
} else if (cmd === shared_consts.FRIENDSCMD.BLOCK_USER) {
+ await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
+ await this.removeReqFriend(idapp, usernameOrig, usernameDest); // Rimuovo la Richiesta di Amicizia da me
+
await this.removeFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
@@ -1784,6 +1797,8 @@ function getWhatToShow(idapp, username) {
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.username_telegram': 1,
+ 'profile.firstname_telegram': 1,
+ 'profile.lastname_telegram': 1,
'profile.intcode_cell': 1,
'profile.cell': 1,
'profile.website': 1,
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index 109931d..1f91609 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -131,7 +131,7 @@ MsgBot = {
HAHA: ['hahaha', 'ahah', 'π'],
MI_AMI: ['mi ami'],
TI_AMO: ['ti amo', 'ti adoro', 'ti lovvo'],
- PREGO: [ 'prego', 'Prego ! πππ'],
+ PREGO: ['prego', 'Prego ! πππ'],
GRAZIE: [
'grazie ainy',
'grazie',
@@ -486,14 +486,14 @@ const txt = {
' Si Γ¨ appena Registrato "%s" (n. %s)\nInvitato da %s',
MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ Abilita Nuova Registrazione:',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
+ MSG_FRIENDS_ACCEPTED: 'β
%s ha accettato la tua richiesta di Amicizia !',
+ MSG_FRIENDS_ACCEPTED_CONFIRMED: 'β
Hai accettato la richiesta di Amicizia di %s !',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Abilitato correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Abilitato correttamente da %s!\n' +
'Vai sulla App oppure clicca qui per entrare\nππ» %s',
MSG_GROUP_CONFIRMED: 'β
Sei stato Aggiunto sul Gruppo %s!',
- MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
- 'π« Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.
Contattalo per farti abilitare !',
- MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
- 'π« %s Non Γ¨ stato Abilitato !',
+ MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK + 'π« Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.
Contattalo per farti abilitare !',
+ MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + 'π« %s Non Γ¨ stato Abilitato !',
MSG_ISCRITTO_CONACREIS: emo.FIRE + ' Si Γ¨ appena Iscritto al Conacreis "%s"',
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
@@ -862,6 +862,47 @@ const MyTelegramBot = {
},
+ askConfirmationUserFriend: async function(idapp, myfunc, myuser, userDest = '', username = '') {
+
+ try {
+ const cl = getclTelegByidapp(idapp);
+
+ const langdest = myuser.lang;
+ const telegid = myuser.profile.teleg_id;
+
+ let keyb = null;
+ let domanda = '';
+
+ const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
+
+ if (myfunc === shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
+
+ domanda = printf(tools.gettranslate('RICHIESTA_AMICIZIA', langdest), userDest) + '
' + struserinfomsg;
+
+ keyb = cl.getInlineKeyboard(myuser.lang, [
+ {
+ text: 'β
π€ Accetta Amicizia',
+ callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
+ },
+ {
+ text: 'π«π€ Rifiuta Amicizia',
+ callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
+ },
+ ]);
+ }
+
+ // Invia Msg
+ if (domanda) {
+ const teleg_id = await User.TelegIdByUsername(idapp, userDest);
+ await this.local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda, undefined, undefined, true, keyb);
+ }
+
+ } catch (e) {
+ console.error('Error askConfirmationUser', e);
+ }
+
+ },
+
sendMsgTelegramToTheManagers: async function(
idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
@@ -1556,10 +1597,10 @@ class Telegram {
} else if (testo.length >= 10) {
noanswer = true;
let myfaq = this.geturlfaq();
- risp = 'Io sono solo un Robot ' + emo.ROBOT_FACE + emo.JOY2 +
- 'Usa il menu qui sotto per interagire col BOT\n' +
- '\n\nPer AIUTO, clicca qui:\nππ»ππ»FAQ di AIUTO (risposte alle domande piΓΉ frequenti)\n\nSe non trovi risposta allora contatta la Chat HELP.\nGrazie';
+ risp = 'Ciao {username}, Io mi chiamo BOT e sono il tuo assistente Virtuale ' + emo.ROBOT_FACE + emo.JOY2 + '\n';
+ 'Usa il menu qui sotto per interagire col BOT\n' +
+ '\n\nPer AIUTO, clicca qui:\nππ»ππ»FAQ di AIUTO (risposte alle domande piΓΉ frequenti)\n\nSe non trovi risposta allora contatta la Chat HELP.\nGrazie';
// risp += '\nClicca qui per entrare nella Chat - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
await local_sendMsgTelegramToTheManagers(this.idapp, testo, msg,
rec.username_bo);
@@ -2353,7 +2394,7 @@ class Telegram {
const msg = await MsgTemplate.getMsgByTitleAndLang(myuser.idapp, title, myuser.lang);
const mytext = tools.convertSpecialTags(myuser, msg.body);
return this.sendMsg(myuser.profile.teleg_id, mytext);
- }catch (e) {
+ } catch (e) {
console.error('ERR sendMsgByTemplate', e);
}
}
@@ -3140,7 +3181,7 @@ class Telegram {
}
try {
- console.log('textORIG', text);
+ console.log('textORIG', text.substring(0, 100));
text = text.replace(/
/g, '\n');
text = text.replace(/
/g, '\n');
text = text.replace(/