- fix link bot for Test Envinroment

- If invite not exist, error message
- Username (where name and surname don't exists).
This commit is contained in:
paoloar77
2022-02-09 19:48:39 +01:00
parent 08b99bf3f8
commit 57a396c374
24 changed files with 106 additions and 65 deletions

View File

@@ -1884,7 +1884,7 @@ UserSchema.statics.SetTelegramWasBlocked = async function(idapp, teleg_id) {
'profile.teleg_id': 0,
};
if (process.env.PROD === '1') {
if (tools.sulServer()) {
const ris = await User.findOneAndUpdate({
idapp,
@@ -1896,7 +1896,7 @@ UserSchema.statics.SetTelegramWasBlocked = async function(idapp, teleg_id) {
};
UserSchema.statics.getNameSurnameByUsername = async function(idapp, username) {
UserSchema.statics.getNameSurnameByUsername = async function(idapp, username, reale = false) {
const User = this;
return User.findOne({
@@ -1904,10 +1904,32 @@ UserSchema.statics.getNameSurnameByUsername = async function(idapp, username) {
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {username: 1, name: 1, surname: 1}).then((rec) => {
let ris = rec.username;
if (!!rec && rec.name) {
ris = (`${rec.name} ${rec.surname}`)
if (!!rec) {
if (reale) {
if (!rec.name)
return ''
ris = `${rec.name} ${rec.surname}`
} else {
if (rec.name) {
ris = `${rec.name} ${rec.surname}`
}
}
}
return (!!rec) ? (`${rec.name} ${rec.surname}`) : '';
return (!!rec) ? ris : '';
}).catch((e) => {
console.error('getNameSurnameByUsername', e);
});
};
UserSchema.statics.getIdByUsername = async function(idapp, username) {
const User = this;
return User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {username: 1, _id: 1}).then((rec) => {
return (!!rec) ? rec._id.toString() : '';
}).catch((e) => {
console.error('getNameSurnameByUsername', e);
});
@@ -2424,6 +2446,17 @@ UserSchema.statics.getUsersTelegramPending = async function(idapp) {
return User.count(myfind);
};
UserSchema.statics.getNumUsers = async function(idapp) {
const User = this;
const myfind = {
idapp,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
};
return User.count(myfind);
};
UserSchema.statics.getUsersZoom = async function(idapp) {
const User = this;