vedere le Richieste di Fiducia solo se si è verificati Telegram

Corretto il mio account che doveva confermare in automatico... non lo faceva...
"Riregistrarsi se l'invitante non ha ancora confermato l'invito.
Annullo la richiesta precedente. (inviando un msg di annullamento. (Si è già registrato con un alto invito.)"
CMyEditor: non posso andare in edit sul HTML (nella table)
Aggiornare il msg di benvenuto ! (prendere da msgtemplate)
Dal Profilo: è possibile inviarsi il messaggio da condividere agli Amici
Visualizzare la data d'inserimento dell'annuncio e l'ultima modifica fatta
Link alla pagina di un Evento o Bene o Servizio !
Se aggiornamento: mettere messaggio che dice di chiudere e riaprire per aggiornare.
Quando un utente chiede di entrare nel Gruppo, mettere l'abilitazione anche su Telegram. (e correggere il msg)
This commit is contained in:
paoloar77
2022-03-06 00:48:33 +01:00
parent 4bc406fba6
commit 466fdd597d
14 changed files with 686 additions and 784 deletions

View File

@@ -1100,13 +1100,6 @@ UserSchema.statics.getLastUser = function(idapp) {
}).sort({index: -1});
};
UserSchema.statics.findByIndOrder = function(idapp, ind_order) {
const User = this;
return User.getRecByIndOrder(idapp, ind_order);
};
UserSchema.statics.findByIndex = function(idapp, index) {
const User = this;
@@ -1606,21 +1599,26 @@ UserSchema.statics.setFriendsCmd = async function(idapp, usernameOrig, usernameD
return ris;
};
UserSchema.statics.setGroupsCmd = async function(
idapp, usernameOrig, groupnameDest, cmd, value) {
UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupnameDest) {
// Controllo se è stato già inserito
return User.findOne({
idapp,
username: usernameOrig,
'profile.mygroups': {
$elemMatch: {groupname: {$eq: groupnameDest}},
},
}).lean();
};
UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameDest, cmd, value) {
let ris = null;
let update = {};
try {
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
// Controllo se è stato già inserito
const foundIfAlreadyGroup = await User.findOne({
idapp,
username: usernameOrig,
'profile.mygroups': {
$elemMatch: {groupname: {$eq: groupnameDest}},
},
});
const foundIfAlreadyGroup = await this.ifAlreadyInGroup(idapp, usernameOrig, groupnameDest);
if (!foundIfAlreadyGroup) {
update = {
@@ -1640,12 +1638,13 @@ UserSchema.statics.setGroupsCmd = async function(
} else {
ris = false;
}
if (ris) {
// Invia una notifica alla persona e agli Admin
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true);
ris = await MyGroup.getInfoGroupByGroupname(idapp, groupnameDest);
}
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
// Aggiungo la richiesta di Amicizia a me
// Aggiungo la richiesta di Gruppo a me
const foundIfAlreadyAskGroup = await MyGroup.findOne({
idapp,
groupname: groupnameDest,
@@ -1669,7 +1668,7 @@ UserSchema.statics.setGroupsCmd = async function(
}
if (ris) {
// Invia una notifica alla persona
tools.sendNotificationByGroupname(idapp, groupnameDest, cmd, true);
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true);
}
} else {
if (foundIfAlreadyAskGroup) {
@@ -1704,7 +1703,7 @@ UserSchema.statics.setGroupsCmd = async function(
},
});
//++Todo: Send Notification to Admin and Group's manager
tools.sendNotificationByGroupname(idapp, groupnameDest, cmd, true);
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, true);
}
} catch (e) {
@@ -1792,7 +1791,7 @@ UserSchema.statics.getInfoFriendByUsername = async function(idapp, username) {
idapp,
username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, whatToShow).then((rec) => !!rec ? rec._doc : null);
}, whatToShow).lean().then((rec) => !!rec ? rec : null);
};
@@ -1805,7 +1804,7 @@ UserSchema.statics.getInfoAskFriendByUsername = async function(
idapp,
username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, whatToShow).then((rec) => !!rec ? rec._doc : null);
}, whatToShow).lean().then((rec) => !!rec ? rec : null);
};
@@ -1910,8 +1909,8 @@ UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
return User.findOne({
idapp, 'profile.teleg_id': teleg_id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).then((rec) => {
return (!!rec) ? rec._doc : null;
}).lean().then((rec) => {
return (!!rec) ? rec : null;
}).catch((e) => {
console.error('UserExistByIdTelegram', e);
});
@@ -1924,7 +1923,7 @@ UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
idapp, 'profile.teleg_id': teleg_id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).lean().then((rec) => {
return (!!rec) ? rec._doc : null;
return (!!rec) ? rec : null;
}).catch((e) => {
console.error('UserExistByIdTelegram', e);
});
@@ -1957,6 +1956,20 @@ UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
console.error('TelegIdByUsername', e);
});
};
UserSchema.statics.TelegIdById = async function(idapp, id) {
const User = this;
return User.findOne({
idapp,
_id: id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {'profile.teleg_id': 1}).lean().then((rec) => {
return (!!rec) ? rec.profile.teleg_id : null;
}).catch((e) => {
console.error('TelegIdByUsername', e);
});
};
UserSchema.statics.notAsk_VerifByUsername = async function(idapp, username) {
return User.findOne({
@@ -2039,13 +2052,6 @@ UserSchema.statics.setUsernameTelegram = async function(
};
UserSchema.statics.getLangByIndOrder = async function(idapp, ind_order) {
const User = this;
const rec = await User.getSmallRecByIndOrder(idapp, ind_order);
return (!!rec) ? rec.lang : '';
};
UserSchema.statics.SetLang = async function(idapp, id, lang) {
const User = this;
@@ -2122,6 +2128,19 @@ UserSchema.statics.getIdByUsername = async function(idapp, username) {
});
};
UserSchema.statics.getRecLangAndIdByUsername = async function(idapp, username) {
const User = this;
return User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {lang: 1, _id: 1}).then((rec) => {
return (!!rec) ? rec : null;
}).catch((e) => {
console.error('getRecLangAndIdByUsername', e);
});
};
UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
const User = this;
@@ -2136,101 +2155,6 @@ UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
});
};
UserSchema.statics.getSmallRecByIndOrder = async function(idapp, ind_order) {
try {
const rec = {};
/*
const rec = await ListaIngresso.getarray(idapp,
{
idapp,
ind_order,
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
},
{
idapp: 1,
index: 1,
ind_order: 1,
old_order: 1,
username: 1,
name: 1,
lang: 1,
surname: 1,
'profile.teleg_id': 1,
});
if (!!rec)
return rec[0];
*/
return null;
} catch (e) {
console.error('getSmallRecByIndOrder', e);
}
};
UserSchema.statics.NuovoSistema = function(idapp) {
const User = this;
try {
return User.findOne({idapp, old_order: {$exists: true}}).then((ris) => {
return !!ris;
});
} catch (e) {
console.error('NuovoSistema', e.message);
}
};
UserSchema.statics.getRecByIndOrder = async function(idapp, ind_order) {
const User = this;
try {
/*
let filters = {
idapp: 1,
index: 1,
ind_order: 1,
old_order: 1,
username: 1,
email: 1,
name: 1,
lang: 1,
surname: 1,
'profile.teleg_id': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.paymenttypes': 1,
};
const rec = await ListaIngresso.getarray(idapp,
{
idapp,
ind_order,
},
filters);
if (!!rec)
return rec[0];
*/
return null;
} catch (e) {
console.error('getRecByIndOrder', e);
}
};
UserSchema.statics.getusersManagers = async function(idapp) {
const User = this;
@@ -2943,13 +2867,6 @@ if (tools.INITDB_FIRSTIME) {
// UserSchema.index({ surname: 1 });
}
UserSchema.statics.getUsernameByIndOrder = async function(idapp, ind_order) {
const myrec = await User.getSmallRecByIndOrder(idapp, ind_order);
return (!!myrec) ? myrec.username : '';
};
UserSchema.statics.getUsernameByIndex = async function(idapp, index) {
const myrec = await User.findOne({
@@ -3221,7 +3138,7 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
{deleted: {$exists: true, $eq: false}}],
}, {username: 1}).lean();
recUser.profile.asked_friends = listSentMyRequestFriends
recUser._doc.profile.asked_friends = listSentMyRequestFriends
? listSentMyRequestFriends
: [];
@@ -3233,9 +3150,9 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
}, MyGroup.getWhatToShow_Unknown());
}, MyGroup.getWhatToShow_Unknown()).lean();
recUser.profile.asked_groups = listSentMyRequestGroups
recUser._doc.profile.asked_groups = listSentMyRequestGroups
? listSentMyRequestGroups
: [];
@@ -3247,12 +3164,14 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
});
}).lean();
recUser.profile.manage_mygroups = listManageGroups
recUser._doc.profile.manage_mygroups = listManageGroups
? listManageGroups
: [];
return recUser._doc;
} catch (e) {
console.error('Err', e);
}