strette di mano
This commit is contained in:
@@ -19,3 +19,7 @@ entrando sul bot riso premi su avvia (o start) e segui le istruzioni
|
||||
|
||||
3️⃣ condividi il progetto ai tuoi amici ed aiuta così a far crescere questa rete e crescere insieme 💚 partecipa al cambiamento. riso sei anche tu.
|
||||
se hai bisogno di aiuto chiedi in questa chat: 👉🏻 chat riso help
|
||||
|
||||
Gio 05/01 ORE 19:28: USER [paoloar77]: vai al sito
|
||||
|
||||
Gio 05/01 ORE 19:28: USER [paoloar77]: link da condividere
|
||||
|
||||
@@ -210,16 +210,21 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif) {
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_action;
|
||||
newdescr = i18n.__('FRIEND_REPORTED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
|
||||
}
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED) {
|
||||
tag = 'unblockeduser';
|
||||
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED_YOU', recnotif.paramsObj.username_worked);
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_worked;
|
||||
} else if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED', recnotif.paramsObj.usernameDest, userorig);
|
||||
} else {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
|
||||
}
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE) {
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_NEW_REC) {
|
||||
newdescr = i18n.__('<strong>%s</strong> asked you for HandShake', userorig, mydescr);
|
||||
tag = 'newfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED) {
|
||||
newdescr = i18n.__('<strong>%s</strong> accepted your HandShake', userorig, mydescr);
|
||||
tag = 'acceptedfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED_MY_REQUEST) {
|
||||
newdescr = i18n.__('✅ You have accepted %s\' HandShake request!', userorig, mydescr);
|
||||
tag = 'acceptedfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_REFUSED) {
|
||||
newdescr = i18n.__('<strong>%s</strong> refused your HandShake', userorig, mydescr);
|
||||
tag = 'refusedfriend';
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
tag = 'group';
|
||||
@@ -450,7 +455,7 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
|
||||
let idapp = req.body.idapp;
|
||||
let check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||
if (!check)
|
||||
if (!check)
|
||||
check = tools.checkUserOk(myrecnotif.sendergroup, user ? myrecnotif.sendergroup : req.user.username, res);
|
||||
if (check.exit) return check.ret;
|
||||
|
||||
@@ -517,6 +522,19 @@ sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlys
|
||||
newstatus = shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED;
|
||||
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) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
||||
dest = myrecnotif.dest;
|
||||
|
||||
@@ -379,6 +379,18 @@ const UserSchema = new mongoose.Schema({
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
handshake: [
|
||||
{
|
||||
_id: false,
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
req_handshake: [
|
||||
{
|
||||
_id: false,
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
mygroups: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -1542,6 +1554,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
||||
'profile.born_province': 1,
|
||||
'profile.born_country': 1,
|
||||
'profile.calc': 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.friends': 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
'useraport.username': 1,
|
||||
@@ -1583,6 +1597,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
||||
'profile.born_province': 1,
|
||||
'profile.born_country': 1,
|
||||
'profile.calc': 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.friends': 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
'useraport.username': 1,
|
||||
@@ -1625,6 +1641,8 @@ UserSchema.statics.getUserProfileByUsername = async function (
|
||||
'profile.born_province': 1,
|
||||
'profile.born_country': 1,
|
||||
'profile.calc': 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.friends': 1,
|
||||
'mycities': 1,
|
||||
'comune': 1,
|
||||
email: 1,
|
||||
@@ -1757,6 +1775,21 @@ UserSchema.statics.getUsernameFriendsByUsername = async function (
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'friends');
|
||||
|
||||
};
|
||||
UserSchema.statics.getUsernameReqHandShakeByUsername = async function (
|
||||
idapp, username) {
|
||||
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'req_handshake');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsernameHandShakeByUsername = async function (
|
||||
idapp, username) {
|
||||
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'handshake');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsernameGroupsByUsername = async function (
|
||||
@@ -1781,6 +1814,13 @@ UserSchema.statics.removeFriend = async function (
|
||||
{ $pull: { 'profile.friends': { username: { $in: [usernameDest] } } } });
|
||||
};
|
||||
|
||||
// Rimuovo l'Amicizia
|
||||
UserSchema.statics.removeHandShake = async function (
|
||||
idapp, username, usernameDest) {
|
||||
return await User.updateOne({ idapp, username },
|
||||
{ $pull: { 'profile.handshake': { username: { $in: [usernameDest] } } } });
|
||||
};
|
||||
|
||||
// Rimuovo il Gruppo
|
||||
UserSchema.statics.removeFromMyGroups = async function (
|
||||
idapp, username, groupnameDest) {
|
||||
@@ -1813,6 +1853,13 @@ UserSchema.statics.removeReqFriend = async function (
|
||||
{ $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) {
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
@@ -1920,6 +1967,87 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
//if (ris) {
|
||||
ris = await User.getInfoFriendByUsername(idapp, usernameDest);
|
||||
//}
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) {
|
||||
// Aggiungo l'Amicizia a me
|
||||
const foundIfAlreadyFriend = await User.findOne({
|
||||
idapp,
|
||||
username: usernameOrig,
|
||||
'profile.handshake': {
|
||||
$elemMatch: { username: { $eq: usernameDest } },
|
||||
},
|
||||
}, { _id: 1 }).lean();
|
||||
|
||||
if (!foundIfAlreadyFriend) {
|
||||
update = {
|
||||
$push: {
|
||||
'profile.handshake': {
|
||||
username: usernameDest,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
};
|
||||
ris = await User.updateOne({ idapp, username: usernameOrig }, update);
|
||||
|
||||
if (!disablenotif) {
|
||||
// Send a notification to the DESTINATION FRIENDSHIP !
|
||||
let req = tools.getReqByPar(idapp, usernameOrig);
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
|
||||
shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED);
|
||||
|
||||
// Send a notification to the SENDER HANDSHAKEHIP !
|
||||
req = tools.getReqByPar(idapp, usernameDest);
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest: usernameOrig }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
|
||||
shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED_MY_REQUEST);
|
||||
|
||||
}
|
||||
|
||||
update = { $pull: { 'profile.req_handshake': { username: { $in: [usernameDest] } } } };
|
||||
ris = await User.updateOne({ idapp, username: usernameOrig }, update);
|
||||
|
||||
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: user.lang }, usernameOrig);
|
||||
const msgOrig = i18n.__({ phrase: '✅ You have accepted %s\' HandShake request!', locale: userDest.lang }, usernameDest);
|
||||
|
||||
await telegrambot.sendMsgTelegram(idapp, usernameDest, msgDest);
|
||||
await telegrambot.sendMsgTelegram(idapp, usernameOrig, 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) {
|
||||
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({
|
||||
@@ -1946,9 +2074,36 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
// Invia una notifica alla persona
|
||||
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.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
|
||||
ris = await this.removeReqHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da me
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1965,6 +2120,15 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
await this.removeFriend(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
|
||||
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) {
|
||||
|
||||
// Rimuovi anche le eventuali richieste di Amicizia !
|
||||
await this.removeReqHandShake(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
||||
await this.removeReqHandShake(idapp, usernameOrig, usernameDest); // Rimuovo la Richiesta di Amicizia da me
|
||||
|
||||
await this.removeHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
|
||||
ris = await this.removeHandShake(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
||||
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
@@ -1975,6 +2139,16 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
||||
ris = await this.removeFriend(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da me
|
||||
|
||||
} 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) {
|
||||
|
||||
await this.removeReqFriend(idapp, usernameDest, usernameOrig); // Rimuovo la Richiesta di Amicizia da lui
|
||||
@@ -2602,6 +2776,8 @@ function getWhatToShow(idapp, username) {
|
||||
'profile.calc': 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
'profile.friends': 1,
|
||||
'profile.handshake': 1,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -2622,8 +2798,9 @@ function getWhatToShow_Unknown(idapp, username) {
|
||||
'profile.born_country': 1,
|
||||
'profile.calc': 1,
|
||||
date_reg: 1,
|
||||
};
|
||||
|
||||
'profile.handshake': 1,
|
||||
'profile.friends': 1,
|
||||
}
|
||||
}
|
||||
|
||||
UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
||||
@@ -2646,7 +2823,8 @@ UserSchema.statics.getWhatToShow_IfFriends = async function (idapp, username) {
|
||||
username_who_report: 1,
|
||||
date_reg: 1,
|
||||
groups: 1,
|
||||
friends: 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.friends': 1,
|
||||
};
|
||||
|
||||
};
|
||||
@@ -2693,6 +2871,23 @@ 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) {
|
||||
|
||||
if (!username) {
|
||||
@@ -2711,6 +2906,10 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
username);
|
||||
const arrUsernameReqFriends = await User.getUsernameReqFriendsByUsername(
|
||||
idapp, username);
|
||||
const arrUsernameHandShake = await User.getUsernameHandShakeByUsername(idapp,
|
||||
username);
|
||||
const arrUsernameReqHandShake = await User.getUsernameReqHandShakeByUsername(
|
||||
idapp, username);
|
||||
|
||||
let listFriends = await User.find({
|
||||
idapp,
|
||||
@@ -2720,6 +2919,14 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
|
||||
let listHandShake = await User.find({
|
||||
idapp,
|
||||
username: { $in: arrUsernameHandShake },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
|
||||
let listRequestFriends = await User.find({
|
||||
idapp,
|
||||
username: { $in: arrUsernameReqFriends },
|
||||
@@ -2728,6 +2935,14 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, 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({
|
||||
idapp,
|
||||
'profile.req_friends': {
|
||||
@@ -2738,6 +2953,16 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, 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({
|
||||
idapp, aportador_solidario: username,
|
||||
'profile.teleg_id': { $gt: 0 },
|
||||
@@ -2748,9 +2973,12 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
|
||||
return {
|
||||
listFriends,
|
||||
listHandShake,
|
||||
listRequestFriends,
|
||||
listRequestHandShake,
|
||||
listTrusted,
|
||||
listSentRequestFriends,
|
||||
listSentRequestHandShake,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
@@ -2759,9 +2987,12 @@ UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||
|
||||
return {
|
||||
listFriends: [],
|
||||
listHandShake: [],
|
||||
listRequestFriends: [],
|
||||
listRequestHandShake: [],
|
||||
listTrusted: [],
|
||||
listSentRequestFriends: [],
|
||||
listSentRequestHandShake: [],
|
||||
|
||||
};
|
||||
};
|
||||
@@ -4298,6 +4529,20 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser) {
|
||||
? 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._doc.profile.asked_handshake = listSentMyRequestHandShake
|
||||
? listSentMyRequestHandShake
|
||||
: [];
|
||||
|
||||
const listSentMyRequestGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'req_users': {
|
||||
|
||||
@@ -975,6 +975,24 @@ const MyTelegramBot = {
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
|
||||
},
|
||||
]);
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_HANDSHAKE) {
|
||||
sendnotif = true;
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE;
|
||||
typeid = shared_consts.TypeNotifs.ID_HANDSHAKE_NEW_REC;
|
||||
paramsObj = { usernameDest: userDest };
|
||||
|
||||
domanda = printf(tools.gettranslate('RICHIESTA_HANDSHAKE', langdest), myuser.username) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅👤 Accetta Stretta di mano',
|
||||
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 + '',
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
// Invia Msg
|
||||
|
||||
@@ -125,6 +125,7 @@ const textlang = {
|
||||
'MSG_SEND_FROM': 'Msg Inviato da',
|
||||
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
|
||||
'RICHIESTA_AMICIZIA': '🌈 Richiesta d\'Amicizia da parte di %s',
|
||||
'RICHIESTA_HANDSHAKE': '🌈 Richiesta Stretta di mano da parte di %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',
|
||||
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
|
||||
@@ -912,6 +913,19 @@ module.exports = {
|
||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_AMICIZIA, userrecDest, username, usernameOrig);
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REQHANDSHAKE) {
|
||||
descr = printf(this.get__('RICHIESTA_HANDSHAKE', lang), usernameOrig);
|
||||
openUrl = '/my/' + usernameOrig;
|
||||
tag = 'reqfriends';
|
||||
|
||||
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
||||
|
||||
if (userrecDest) {
|
||||
sendmynotif = false; // non lo rimandare 2 volte !
|
||||
// SEND TELEGRAM NOTIFICATION
|
||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -493,6 +493,20 @@ module.exports = {
|
||||
});
|
||||
console.log('req_friends.username result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, 'profile.handshake.username': search_username },
|
||||
{
|
||||
$set:
|
||||
{ 'profile.handshake.$.username': replace_username }
|
||||
});
|
||||
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 },
|
||||
{ $set: { 'admins.$.username': replace_username } });
|
||||
console.log('Circuit.admins.username result = ', ris);
|
||||
|
||||
@@ -45,10 +45,15 @@ module.exports = {
|
||||
FRIENDSCMD: {
|
||||
SETTRUST: 121,
|
||||
REQFRIEND: 125,
|
||||
REQHANDSHAKE: 128,
|
||||
SETFRIEND: 132,
|
||||
SETHANDSHAKE: 133,
|
||||
REMOVE_FROM_MYFRIENDS: 144,
|
||||
REFUSE_REQ_FRIEND: 145,
|
||||
CANCEL_REQ_FRIEND: 146,
|
||||
REMOVE_FROM_MYHANDSHAKE: 147,
|
||||
REFUSE_REQ_HANDSHAKE: 148,
|
||||
CANCEL_REQ_HANDSHAKE: 149,
|
||||
BLOCK_USER: 155,
|
||||
UNBLOCK_USER: 156,
|
||||
REPORT_USER: 158,
|
||||
@@ -283,6 +288,7 @@ module.exports = {
|
||||
REGISTRATION: 6,
|
||||
RICHIESTA_GRUPPO: 10,
|
||||
RICHIESTA_AMICIZIA: 15,
|
||||
RICHIESTA_HANDSHAKE: 16,
|
||||
RICHIESTA_CIRCUIT: 20,
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user