l'admin non riesce a cambiare il fido degli utenti...
This commit is contained in:
@@ -920,7 +920,6 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
||||
strProv: province,
|
||||
photos: [],
|
||||
admins: [],
|
||||
color: '#ff5500',
|
||||
deperimento: false,
|
||||
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
||||
@@ -966,6 +965,49 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListAdmins = async function (idapp, circuitname) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
name: circuitname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
let mystr = '';
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
mystr += await tools.getAhref(admin.username, await tools.getLinkUserTelegram(idapp, admin.username)) + ', ';
|
||||
}
|
||||
}
|
||||
|
||||
return {str: mystr, num: arr ? arr.admins.length : 0};
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.isAdminCircuit = async function (idapp, circuitname, username) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
name: circuitname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
if (admin.username === username)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, username, groupname) {
|
||||
|
||||
let mystr = '';
|
||||
|
||||
Reference in New Issue
Block a user