- MyProfile

- Immagine profilo e small
This commit is contained in:
paoloar77
2022-01-03 21:53:50 +01:00
parent b587b5e0a7
commit 181af3c895
7 changed files with 447 additions and 326 deletions

View File

@@ -865,7 +865,8 @@ UserSchema.statics.setUserQualified = async function(idapp, username) {
return !!myrec;
};
UserSchema.statics.setVerifiedByAportador = async function(idapp, username, valuebool) {
UserSchema.statics.setVerifiedByAportador = async function(
idapp, username, valuebool) {
const User = this;
if (username === undefined)
@@ -882,13 +883,13 @@ UserSchema.statics.setVerifiedByAportador = async function(idapp, username, valu
return !!myrec;
};
UserSchema.statics.setVerifiedByAportadorToALL = async function () {
UserSchema.statics.setVerifiedByAportadorToALL = async function() {
return User.updateMany({}, {$set: {'verified_by_aportador': true}}, {new: false});
return User.updateMany({}, {$set: {'verified_by_aportador': true}},
{new: false});
};
UserSchema.statics.setUserQualified_2Invitati = async function(
idapp, username) {
const User = this;
@@ -1147,6 +1148,51 @@ UserSchema.statics.getUserById = function(idapp, id) {
});
};
UserSchema.statics.getUserProfileByUsername = async function(idapp, username) {
let perm = tools.Perm.PERM_ALL; //++Todo: sistemare
let whatToShow = {};
if (perm === tools.Perm.PERM_ALL) {
whatToShow = {
lang: 1,
index: 1,
username: 1,
aportador_solidario: 1,
name: 1,
surname: 1,
deleted: 1,
sospeso: 1,
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
'profile.username_telegram': 1,
'profile.img': 1,
'profile.sex': 1,
'profile.dateofbirth': 1,
'profile.born_city': 1,
'profile.born_province': 1,
'profile.born_country': 1,
email: 1,
date_reg: 1,
img: 1,
};
}
return User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, whatToShow).then((rec) => {
return (rec._doc);
}).catch((e) => {
return null;
});
};
UserSchema.statics.getAportadorSolidarioByUsername = async function(
idapp, username) {
const User = this;