Corretto le richieste di amicizie, aggiunto Accettazione sul BOT
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user