Lista Città (prese dal server: pickup)

This commit is contained in:
paoloar77
2022-01-20 00:39:06 +01:00
parent f463f88495
commit 66eaca6d41
11 changed files with 97289 additions and 56 deletions

View File

@@ -282,6 +282,9 @@ const UserSchema = new mongoose.Schema({
biografia: {
type: String,
},
qualifica: {
type: String,
},
motivazioni: {
type: String,
},
@@ -1189,6 +1192,7 @@ UserSchema.statics.getUserProfileByUsername = async function(idapp, username) {
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
'profile.username_telegram': 1,
@@ -1283,7 +1287,7 @@ UserSchema.statics.setFriendsCmd = async function(
idapp,
username: usernameOrig,
'profile.friends': {
$elemMatch: {$eq: {username: usernameDest}},
$elemMatch: {username: {$eq: usernameDest}},
},
});
@@ -1307,7 +1311,7 @@ UserSchema.statics.setFriendsCmd = async function(
idapp,
username: usernameDest,
'profile.friends': {
$elemMatch: {$eq: {username: usernameOrig}},
$elemMatch: {username: {$eq: usernameOrig}},
},
});
@@ -1333,7 +1337,7 @@ UserSchema.statics.setFriendsCmd = async function(
idapp,
username: usernameDest,
'profile.req_friends': {
$elemMatch: {$eq: {username: usernameOrig}},
$elemMatch: { username: {$eq: usernameOrig}},
},
});
@@ -1407,6 +1411,7 @@ function getWhatToShow(idapp, username) {
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.username_telegram': 1,
'profile.img': 1,
@@ -1471,7 +1476,7 @@ UserSchema.statics.getAskedFriendsByUsername = async function(idapp, username) {
return User.find({
idapp,
'profile.req_friends': {
$elemMatch: {$eq: {username: username}},
$elemMatch: {username: {$eq: username}},
},
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, whatToShow_Unknown).then((rec) => {
@@ -1510,7 +1515,7 @@ UserSchema.statics.getFriendsByUsername = async function(idapp, username) {
let listSentRequestFriends = await User.find({
idapp,
'profile.req_friends': {
$elemMatch: {$eq: {username: username}},
$elemMatch: {username: {$eq: username}},
},
$or: [
{deleted: {$exists: false}},
@@ -3134,6 +3139,27 @@ UserSchema.statics.DbOp = async function(idapp, mydata) {
};
UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
try {
const listSentMyRequestFriends = await User.find({
idapp,
'profile.req_friends': {
$elemMatch: {username: {$eq: recUser.username}},
},
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
}, {username: 1});
recUser._doc.profile.asked_friends = listSentMyRequestFriends ? listSentMyRequestFriends : [];
}catch (e){
console.error('Err', e);
}
return recUser;
};
UserSchema.statics.createNewSubRecord = async function(idapp, req) {
const User = this;