ver: 0.5.55
Strette di Mano OK
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"L'Email è già stata Verificata": "L'Email è già stata Verificata"
|
"L'Email è già stata Verificata": "L'Email è già stata Verificata",
|
||||||
"Email Verificata!": "Email Verificada! Cierre esta ventana y regrese a la otra.",
|
"Email Verificata!": "Email Verificada! Cierre esta ventana y regrese a la otra.",
|
||||||
"Nuova Registrazione": "Nuevo Registro",
|
"Nuova Registrazione": "Nuevo Registro",
|
||||||
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
|
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
|
||||||
|
|||||||
@@ -11,11 +11,7 @@
|
|||||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
||||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||||
"<strong>%s</strong> asked you HandShake": "<strong>%s</strong> ti ha chiesto la Stretta di mano",
|
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha fiducia in te.",
|
||||||
"<strong>%s</strong> accepted your HandShake": "<strong>%s</strong> ha accettato la Stretta di mano",
|
|
||||||
"<strong>%s</strong> refused your HandShake": "<strong>%s</strong> ha rifiutato la Stretta di mano",
|
|
||||||
"✅ %s accepted your HandShake request !": "✅ %s ha accettato la tua richiesta di Stretta di mano !",
|
|
||||||
"✅ You have accepted %s HandShake request!": "✅ Hai accettato la richiesta di Stretta di mano di %s !",
|
|
||||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||||
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
||||||
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
||||||
|
|||||||
@@ -213,18 +213,9 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif) {
|
|||||||
}
|
}
|
||||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE) {
|
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE) {
|
||||||
recnotif.openUrl = '/my/' + userorig;
|
recnotif.openUrl = '/my/' + userorig;
|
||||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_NEW_REC) {
|
if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED) {
|
||||||
newdescr = i18n.__('<strong>%s</strong> asked you HandShake', userorig, mydescr);
|
newdescr = i18n.__('HANDSHAKE_SET', userorig, mydescr);
|
||||||
tag = 'newhandshake';
|
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED) {
|
|
||||||
newdescr = i18n.__('<strong>%s</strong> accepted your HandShake', userorig, mydescr);
|
|
||||||
tag = 'acceptedhandshake';
|
tag = 'acceptedhandshake';
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED_MY_REQUEST) {
|
|
||||||
newdescr = i18n.__('✅ You have accepted %s HandShake request!', userorig, mydescr);
|
|
||||||
tag = 'acceptedhandshake';
|
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_REFUSED) {
|
|
||||||
newdescr = i18n.__('<strong>%s</strong> refused your HandShake', userorig, mydescr);
|
|
||||||
tag = 'refusedhandshake';
|
|
||||||
}
|
}
|
||||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||||
tag = 'group';
|
tag = 'group';
|
||||||
@@ -522,19 +513,6 @@ sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlys
|
|||||||
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
|
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
|
||||||
dest = myrecnotif.sender;
|
dest = myrecnotif.sender;
|
||||||
}
|
}
|
||||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE) {
|
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_HANDSHAKE_NEW_REC;
|
|
||||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED) {
|
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_HANDSHAKE_ACCEPTED;
|
|
||||||
dest = myrecnotif.sender;
|
|
||||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED_MY_REQUEST) {
|
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_HANDSHAKE_ACCEPTED;
|
|
||||||
newdest = myrecnotif.sender;
|
|
||||||
sender = myrecnotif.dest;
|
|
||||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_REFUSED) {
|
|
||||||
newstatus = shared_consts.StatusNotifs.STATUS_HANDSHAKE_REFUSED;
|
|
||||||
dest = myrecnotif.sender;
|
|
||||||
}
|
|
||||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||||
dest = myrecnotif.dest;
|
dest = myrecnotif.dest;
|
||||||
|
|||||||
@@ -385,12 +385,6 @@ const UserSchema = new mongoose.Schema({
|
|||||||
username: { type: String },
|
username: { type: String },
|
||||||
date: { type: Date },
|
date: { type: Date },
|
||||||
}], // username
|
}], // username
|
||||||
req_handshake: [
|
|
||||||
{
|
|
||||||
_id: false,
|
|
||||||
username: { type: String },
|
|
||||||
date: { type: Date },
|
|
||||||
}], // username
|
|
||||||
mygroups: [
|
mygroups: [
|
||||||
{
|
{
|
||||||
_id: false,
|
_id: false,
|
||||||
@@ -1565,7 +1559,6 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.req_handshake': 1,
|
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
@@ -1610,7 +1603,6 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.req_handshake': 1,
|
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
@@ -1655,7 +1647,6 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
|||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
'profile.calc': 1,
|
'profile.calc': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.req_handshake': 1,
|
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'mycities': 1,
|
'mycities': 1,
|
||||||
'comune': 1,
|
'comune': 1,
|
||||||
@@ -1789,13 +1780,6 @@ UserSchema.statics.getUsernameFriendsByUsername = async function (
|
|||||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||||
'friends');
|
'friends');
|
||||||
|
|
||||||
};
|
|
||||||
UserSchema.statics.getUsernameReqHandShakeByUsername = async function (
|
|
||||||
idapp, username) {
|
|
||||||
|
|
||||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
|
||||||
'req_handshake');
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.getUsernameHandShakeByUsername = async function (
|
UserSchema.statics.getUsernameHandShakeByUsername = async function (
|
||||||
@@ -1867,13 +1851,6 @@ UserSchema.statics.removeReqFriend = async function (
|
|||||||
{ $pull: { 'profile.req_friends': { username: { $in: [usernameDest] } } } });
|
{ $pull: { 'profile.req_friends': { username: { $in: [usernameDest] } } } });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Rimuovo la Stretta di Mano
|
|
||||||
UserSchema.statics.removeReqHandShake = async function (
|
|
||||||
idapp, username, usernameDest) {
|
|
||||||
return await User.updateOne({ idapp, username: username },
|
|
||||||
{ $pull: { 'profile.req_handshake': { username: { $in: [usernameDest] } } } });
|
|
||||||
};
|
|
||||||
|
|
||||||
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
||||||
|
|
||||||
const { SendNotif } = require('../models/sendnotif');
|
const { SendNotif } = require('../models/sendnotif');
|
||||||
@@ -2004,52 +1981,12 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
|
|
||||||
if (!disablenotif) {
|
if (!disablenotif) {
|
||||||
// Send a notification to the DESTINATION HANDSHAKE !
|
// Send a notification to the DESTINATION HANDSHAKE !
|
||||||
let req = tools.getReqByPar(idapp, usernameOrig);
|
let req = tools.getReqByPar(idapp, usernameDest);
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
|
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest: usernameOrig }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
|
||||||
shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED_MY_REQUEST);
|
shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ris) {
|
|
||||||
try {
|
|
||||||
if (!disablenotif) {
|
|
||||||
const userDest = await User.getRecLangAndIdByUsername(idapp, usernameDest);
|
|
||||||
const user = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
|
||||||
const msgDest = i18n.__({ phrase: '✅ %s accepted your HandShake request !', locale: userDest.lang }, usernameDest);
|
|
||||||
const msgOrig = i18n.__({ phrase: '✅ You have accepted %s HandShake request!', locale: user.lang }, usernameOrig);
|
|
||||||
|
|
||||||
await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgDest);
|
|
||||||
await telegrambot.sendMsgTelegram(idapp, usernameDest, msgOrig);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Notification : ', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controlla se lui aveva già la mia amicizia
|
|
||||||
const foundIfAlreadyFriend2 = await User.findOne({
|
|
||||||
idapp,
|
|
||||||
username: usernameDest,
|
|
||||||
'profile.handshake': {
|
|
||||||
$elemMatch: { username: { $eq: usernameOrig } },
|
|
||||||
},
|
|
||||||
}, { _id: 1 }).lean();
|
|
||||||
|
|
||||||
if (!foundIfAlreadyFriend2) {
|
|
||||||
update = {
|
|
||||||
$push: {
|
|
||||||
'profile.handshake': {
|
|
||||||
username: usernameOrig,
|
|
||||||
date: new Date(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
ris = await User.updateOne({ idapp, username: usernameDest }, update);
|
|
||||||
|
|
||||||
this.removeReqHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
|
|
||||||
this.removeReqHandShake(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da te
|
|
||||||
}
|
|
||||||
//if (ris) {
|
//if (ris) {
|
||||||
ris = await User.getInfoFriendByUsername(idapp, usernameDest);
|
ris = await User.getInfoFriendByUsername(idapp, usernameDest);
|
||||||
//}
|
//}
|
||||||
@@ -2080,42 +2017,6 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
|
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.REQHANDSHAKE) {
|
|
||||||
// Aggiungo la richiesta di Amicizia a me
|
|
||||||
const foundIfAlreadyAskFriend = await User.findOne({
|
|
||||||
idapp,
|
|
||||||
username: usernameDest,
|
|
||||||
'profile.req_handshake': {
|
|
||||||
$elemMatch: { username: { $eq: usernameOrig } },
|
|
||||||
},
|
|
||||||
}, { _id: 1 }).lean();
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
if (!foundIfAlreadyAskFriend) {
|
|
||||||
update = {
|
|
||||||
$push: {
|
|
||||||
'profile.req_handshake': {
|
|
||||||
username: usernameOrig,
|
|
||||||
date: new Date(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
ris = await User.updateOne({ idapp, username: usernameDest }, update);
|
|
||||||
}
|
|
||||||
if (ris) {
|
|
||||||
// Invia una notifica alla persona
|
|
||||||
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (foundIfAlreadyAskFriend) {
|
|
||||||
ris = await this.removeReqHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (ris) {
|
|
||||||
ris = await User.getInfoAskFriendByUsername(idapp, usernameDest);
|
|
||||||
// }
|
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) {
|
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) {
|
||||||
|
|
||||||
// Rimuovi anche le eventuali richieste di Amicizia !
|
// Rimuovi anche le eventuali richieste di Amicizia !
|
||||||
@@ -2127,7 +2028,7 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) {
|
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) {
|
||||||
|
|
||||||
ris = await this.removeHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
|
ris = await this.removeHandShake(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da lui
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
||||||
|
|
||||||
@@ -2136,16 +2037,6 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||||
shared_consts.TypeNotifs.ID_FRIENDS_REFUSED);
|
shared_consts.TypeNotifs.ID_FRIENDS_REFUSED);
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_HANDSHAKE) {
|
|
||||||
|
|
||||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
|
||||||
const req = tools.getReqByPar(idapp, usernameOrig);
|
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
|
|
||||||
shared_consts.TypeNotifs.ID_HANDSHAKE_REFUSED);
|
|
||||||
|
|
||||||
await this.removeReqHandShake(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
|
||||||
ris = await this.removeHandShake(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.BLOCK_USER) {
|
} 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, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
||||||
@@ -2775,7 +2666,6 @@ function getWhatToShow(idapp, username) {
|
|||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
'profile.friends': 1,
|
'profile.friends': 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
'profile.req_handshake': 1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2869,22 +2759,6 @@ UserSchema.statics.getAskedFriendsByUsername = async function (idapp, username)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.getAskedHandShakeByUsername = async function (idapp, username) {
|
|
||||||
|
|
||||||
const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username);
|
|
||||||
|
|
||||||
return await User.find({
|
|
||||||
idapp,
|
|
||||||
'profile.req_handshake': {
|
|
||||||
$elemMatch: { username: { $eq: username } },
|
|
||||||
},
|
|
||||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
|
||||||
}, whatToShow_Unknown).then((rec) => {
|
|
||||||
|
|
||||||
//return rec.map(m => m.username);
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||||
|
|
||||||
@@ -2894,8 +2768,6 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
listRequestFriends: [],
|
listRequestFriends: [],
|
||||||
listTrusted: [],
|
listTrusted: [],
|
||||||
listSentRequestFriends: [],
|
listSentRequestFriends: [],
|
||||||
listSentRequestHandShake: [],
|
|
||||||
listRequestHandShake: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2908,8 +2780,6 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
idapp, username);
|
idapp, username);
|
||||||
const arrUsernameHandShake = await User.getUsernameHandShakeByUsername(idapp,
|
const arrUsernameHandShake = await User.getUsernameHandShakeByUsername(idapp,
|
||||||
username);
|
username);
|
||||||
const arrUsernameReqHandShake = await User.getUsernameReqHandShakeByUsername(
|
|
||||||
idapp, username);
|
|
||||||
|
|
||||||
let listFriends = await User.find({
|
let listFriends = await User.find({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -2935,14 +2805,6 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown);
|
}, whatToShow_Unknown);
|
||||||
|
|
||||||
let listRequestHandShake = await User.find({
|
|
||||||
idapp,
|
|
||||||
username: { $in: arrUsernameReqHandShake },
|
|
||||||
$or: [
|
|
||||||
{ deleted: { $exists: false } },
|
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
|
||||||
}, whatToShow_Unknown);
|
|
||||||
|
|
||||||
let listSentRequestFriends = await User.find({
|
let listSentRequestFriends = await User.find({
|
||||||
idapp,
|
idapp,
|
||||||
'profile.req_friends': {
|
'profile.req_friends': {
|
||||||
@@ -2953,16 +2815,6 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown);
|
}, whatToShow_Unknown);
|
||||||
|
|
||||||
let listSentRequestHandShake = await User.find({
|
|
||||||
idapp,
|
|
||||||
'profile.req_handshake': {
|
|
||||||
$elemMatch: { username: { $eq: username } },
|
|
||||||
},
|
|
||||||
$or: [
|
|
||||||
{ deleted: { $exists: false } },
|
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
|
||||||
}, whatToShow_Unknown);
|
|
||||||
|
|
||||||
let listTrusted = await User.find({
|
let listTrusted = await User.find({
|
||||||
idapp, aportador_solidario: username,
|
idapp, aportador_solidario: username,
|
||||||
'profile.teleg_id': { $gt: 0 },
|
'profile.teleg_id': { $gt: 0 },
|
||||||
@@ -2975,10 +2827,8 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
listFriends,
|
listFriends,
|
||||||
listHandShake,
|
listHandShake,
|
||||||
listRequestFriends,
|
listRequestFriends,
|
||||||
listRequestHandShake,
|
|
||||||
listTrusted,
|
listTrusted,
|
||||||
listSentRequestFriends,
|
listSentRequestFriends,
|
||||||
listSentRequestHandShake,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -2989,10 +2839,8 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
|||||||
listFriends: [],
|
listFriends: [],
|
||||||
listHandShake: [],
|
listHandShake: [],
|
||||||
listRequestFriends: [],
|
listRequestFriends: [],
|
||||||
listRequestHandShake: [],
|
|
||||||
listTrusted: [],
|
listTrusted: [],
|
||||||
listSentRequestFriends: [],
|
listSentRequestFriends: [],
|
||||||
listSentRequestHandShake: [],
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -4152,7 +4000,8 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
|
|||||||
const query = [
|
const query = [
|
||||||
{
|
{
|
||||||
$match: {
|
$match: {
|
||||||
idapp,
|
idapp: "13",
|
||||||
|
'profile.handshake': { $exists: true },
|
||||||
$or: [
|
$or: [
|
||||||
{
|
{
|
||||||
deleted: {
|
deleted: {
|
||||||
@@ -4168,22 +4017,16 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
$group: {
|
$group:
|
||||||
_id: "$profile.handshake",
|
{
|
||||||
count: {
|
_id: "$username",
|
||||||
$sum: 1,
|
count:
|
||||||
},
|
{ $sum: { $size: "$profile.handshake" } }
|
||||||
},
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
$match: { "count": { $gte: 2 } }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$sort: {
|
|
||||||
count: -1,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
{ $sort: { count: -1 } },
|
||||||
{ $limit: 20 },
|
{ $limit: 20 },
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
@@ -4604,20 +4447,20 @@ UserSchema.statics.getExtraInfoByUsername = async function (idapp, username) {
|
|||||||
|
|
||||||
let myuser = await User.findOne({ idapp, username }).lean();
|
let myuser = await User.findOne({ idapp, username }).lean();
|
||||||
if (myuser) {
|
if (myuser) {
|
||||||
myuserextra = await User.addExtraInfo(idapp, myuser);
|
myuserextra = await User.addExtraInfo(idapp, myuser, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return myuser.profile;
|
return myuser.profile;
|
||||||
|
|
||||||
};
|
};
|
||||||
UserSchema.statics.addExtraInfo = async function (idapp, recUser) {
|
UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (recUser.profile && recUser.profile.notifs && recUser.profile.notifs.length <= 0) {
|
if (recUserSave && recUser.profile && recUser.profile.notifs && recUser.profile.notifs.length <= 0) {
|
||||||
recUser.profile.notifs = shared_consts.DEFAULT_NOTIFS_USER;
|
recUser.profile.notifs = shared_consts.DEFAULT_NOTIFS_USER;
|
||||||
await recUser.save();
|
await recUserSave.save();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Err addExtraInfo notifs ', e);
|
console.error('Err addExtraInfo notifs ', e);
|
||||||
@@ -4637,20 +4480,6 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser) {
|
|||||||
? listSentMyRequestFriends
|
? listSentMyRequestFriends
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const listSentMyRequestHandShake = await User.find({
|
|
||||||
idapp,
|
|
||||||
'profile.req_handshake': {
|
|
||||||
$elemMatch: { username: { $eq: recUser.username } },
|
|
||||||
},
|
|
||||||
$or: [
|
|
||||||
{ deleted: { $exists: false } },
|
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
|
||||||
}, { username: 1 }).lean();
|
|
||||||
|
|
||||||
recUser.profile.asked_handshake = listSentMyRequestHandShake
|
|
||||||
? listSentMyRequestHandShake
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const listSentMyRequestGroups = await MyGroup.find({
|
const listSentMyRequestGroups = await MyGroup.find({
|
||||||
idapp,
|
idapp,
|
||||||
'req_users': {
|
'req_users': {
|
||||||
|
|||||||
@@ -1347,7 +1347,7 @@ function load(req, res, version) {
|
|||||||
let myuserextra = null;
|
let myuserextra = null;
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
|
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
|
||||||
myuserextra = User.addExtraInfo(idapp, req.user._doc);
|
myuserextra = User.addExtraInfo(idapp, req.user._doc, req.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
|||||||
@@ -986,13 +986,9 @@ const MyTelegramBot = {
|
|||||||
|
|
||||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||||
{
|
{
|
||||||
text: '✅👤 Accetta Stretta di mano',
|
text: '✅🤝 Ricambia la fiducia',
|
||||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
|
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
text: '🚫👤 Rifiuta Stretta di mano',
|
|
||||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4129,19 +4125,6 @@ if (true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_HANDSHAKE) {
|
|
||||||
|
|
||||||
if (userDest) {
|
|
||||||
cmd = shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE;
|
|
||||||
// Rimuovilo nelle HandShake
|
|
||||||
const req = tools.getReqByPar(user.idapp, username_action);
|
|
||||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
|
||||||
if (ris) {
|
|
||||||
const msgDest = printf(getstr(user.lang, 'MSG_HANDSHAKE_NOT_ACCEPTED_CONFIRMED'), data.username);
|
|
||||||
|
|
||||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ const textlang = {
|
|||||||
'MSG_SEND_FROM': 'Msg Inviato da',
|
'MSG_SEND_FROM': 'Msg Inviato da',
|
||||||
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
|
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
|
||||||
'RICHIESTA_AMICIZIA': '🌈 Richiesta d\'Amicizia da parte di %s',
|
'RICHIESTA_AMICIZIA': '🌈 Richiesta d\'Amicizia da parte di %s',
|
||||||
'RICHIESTA_HANDSHAKE': '🌈 Confermi che hai conosciuto personalmente e dai la tua fiducia a %s ?',
|
'RICHIESTA_HANDSHAKE': '🌈 %s ha comunicato che ti conosce personalmente e ha fiducia in te.',
|
||||||
'ACCETTATO_SUL_GRUPPO': '✅ Sei stato accettato da %s a far parte del Gruppo %s',
|
'ACCETTATO_SUL_GRUPPO': '✅ Sei stato accettato da %s a far parte del Gruppo %s',
|
||||||
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
|
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
|
||||||
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||||
@@ -913,17 +913,21 @@ module.exports = {
|
|||||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_AMICIZIA, userrecDest, username, usernameOrig);
|
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_AMICIZIA, userrecDest, username, usernameOrig);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.REQHANDSHAKE) {
|
} else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) {
|
||||||
descr = printf(this.get__('RICHIESTA_HANDSHAKE', lang), usernameOrig);
|
descr = printf(this.get__('RICHIESTA_HANDSHAKE', lang), usernameOrig);
|
||||||
openUrl = '/my/' + usernameOrig;
|
openUrl = '/my/' + usernameOrig;
|
||||||
tag = 'reqfriends';
|
tag = 'reqhandshake';
|
||||||
|
|
||||||
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
||||||
|
|
||||||
|
const foundIfAlreadyHandShake = await User.isMyHandShake(idapp, username, usernameOrig);
|
||||||
|
|
||||||
if (userrecDest) {
|
if (userrecDest) {
|
||||||
sendmynotif = false; // non lo rimandare 2 volte !
|
sendmynotif = false; // non lo rimandare 2 volte !
|
||||||
// SEND TELEGRAM NOTIFICATION
|
if (!foundIfAlreadyHandShake) {
|
||||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
|
// SEND TELEGRAM NOTIFICATION
|
||||||
|
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,13 +500,6 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
console.log('handshake.username result = ', ris);
|
console.log('handshake.username result = ', ris);
|
||||||
|
|
||||||
ris = await User.updateMany({ idapp, 'profile.req_handshake.username': search_username },
|
|
||||||
{
|
|
||||||
$set:
|
|
||||||
{ 'profile.req_handshake.$.username': replace_username }
|
|
||||||
});
|
|
||||||
console.log('req_handshake.username result = ', ris);
|
|
||||||
|
|
||||||
ris = await Circuit.updateMany({ idapp, 'admins.username': search_username },
|
ris = await Circuit.updateMany({ idapp, 'admins.username': search_username },
|
||||||
{ $set: { 'admins.$.username': replace_username } });
|
{ $set: { 'admins.$.username': replace_username } });
|
||||||
console.log('Circuit.admins.username result = ', ris);
|
console.log('Circuit.admins.username result = ', ris);
|
||||||
|
|||||||
@@ -45,15 +45,12 @@ module.exports = {
|
|||||||
FRIENDSCMD: {
|
FRIENDSCMD: {
|
||||||
SETTRUST: 121,
|
SETTRUST: 121,
|
||||||
REQFRIEND: 125,
|
REQFRIEND: 125,
|
||||||
REQHANDSHAKE: 128,
|
|
||||||
SETFRIEND: 132,
|
SETFRIEND: 132,
|
||||||
SETHANDSHAKE: 133,
|
SETHANDSHAKE: 133,
|
||||||
REMOVE_FROM_MYFRIENDS: 144,
|
REMOVE_FROM_MYFRIENDS: 144,
|
||||||
REFUSE_REQ_FRIEND: 145,
|
REFUSE_REQ_FRIEND: 145,
|
||||||
CANCEL_REQ_FRIEND: 146,
|
CANCEL_REQ_FRIEND: 146,
|
||||||
REMOVE_FROM_MYHANDSHAKE: 147,
|
REMOVE_FROM_MYHANDSHAKE: 147,
|
||||||
REFUSE_REQ_HANDSHAKE: 148,
|
|
||||||
CANCEL_REQ_HANDSHAKE: 149,
|
|
||||||
BLOCK_USER: 155,
|
BLOCK_USER: 155,
|
||||||
UNBLOCK_USER: 156,
|
UNBLOCK_USER: 156,
|
||||||
REPORT_USER: 158,
|
REPORT_USER: 158,
|
||||||
@@ -426,10 +423,7 @@ module.exports = {
|
|||||||
ID_MSGS_NEW_REC: 1,
|
ID_MSGS_NEW_REC: 1,
|
||||||
|
|
||||||
TYPEDIR_HANDSHAKE: 10,
|
TYPEDIR_HANDSHAKE: 10,
|
||||||
ID_HANDSHAKE_NEW_REC: 1,
|
|
||||||
ID_HANDSHAKE_ACCEPTED: 2,
|
ID_HANDSHAKE_ACCEPTED: 2,
|
||||||
ID_HANDSHAKE_REFUSED: 4,
|
|
||||||
ID_HANDSHAKE_ACCEPTED_MY_REQUEST: 8,
|
|
||||||
|
|
||||||
TYPEDIR_TEST: 444,
|
TYPEDIR_TEST: 444,
|
||||||
ID_TEST_NEW_REC: 1,
|
ID_TEST_NEW_REC: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user