fix strette di mano

This commit is contained in:
Surya Paolo
2023-01-09 04:05:11 +01:00
parent a4b42a1fc3
commit dd51982795

View File

@@ -1968,6 +1968,8 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
},
}, { _id: 1 }).lean();
let rec = null;
if (!foundIfAlreadyFriend) {
update = {
$push: {
@@ -1977,19 +1979,19 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
},
},
};
ris = await User.updateOne({ idapp, username: usernameDest }, update);
rec = await User.updateOne({ idapp, username: usernameDest }, update);
if (!disablenotif) {
// Send a notification to the DESTINATION HANDSHAKE !
let req = tools.getReqByPar(idapp, usernameDest);
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest: usernameOrig }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
let req = tools.getReqByPar(idapp, usernameOrig);
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest }, true, shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE,
shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED);
}
}
//if (ris) {
ris = await User.getInfoFriendByUsername(idapp, usernameDest);
//}
const userprofile = await User.getInfoFriendByUsername(idapp, usernameDest);
const myuser = await User.getInfoFriendByUsername(idapp, usernameOrig);
ris = {rec, userprofile, myuser };
} else if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
// Aggiungo la richiesta di Amicizia a me
const foundIfAlreadyAskFriend = await User.findOne({
@@ -2028,7 +2030,7 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) {
ris = await this.removeHandShake(idapp, usernameOrig, usernameDest); // Rimuovo l'Amicizia da lui
ris = await this.removeHandShake(idapp, usernameDest, usernameOrig); // Rimuovo l'Amicizia da lui
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {