Mostrare il Bene, Servizio, solo ai Propri Gruppi.

Nella pagina profilo, i "Gruppi" personali non si vedevano !
This commit is contained in:
Paolo Arena
2022-06-16 20:34:42 +02:00
parent d8aa8e546e
commit c3b0a1f417
17 changed files with 170 additions and 52 deletions

View File

@@ -14,7 +14,7 @@ mongoose.plugin(schema => {
});
const CircuitSchema = new Schema({
_id: {
Num: {
type: Number,
unique: true,
},
@@ -116,15 +116,15 @@ CircuitSchema.statics.findAllIdApp = async function(idapp) {
CircuitSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
const myrec = await Circuit.findOne().limit(1).sort({Num: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
if (myrec._doc.Num === 0)
this.Num = 1;
else
this._id = myrec._doc._id + 1;
this.Num = myrec._doc.Num + 1;
} else {
this._id = 1;
this.Num = 1;
}
}

View File

@@ -134,7 +134,7 @@ MyBachecaSchema.statics.getFieldsLastForSearch = function() {
};
MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -154,6 +154,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
dateTimeStart: 1,
dateTimeEnd: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
@@ -168,6 +169,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -175,7 +177,7 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
@@ -243,6 +245,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -259,6 +262,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -297,6 +301,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -313,6 +318,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -351,6 +357,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -367,6 +374,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -405,6 +413,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -421,6 +430,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -459,6 +469,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -475,6 +486,7 @@ MyBachecaSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -264,9 +264,9 @@ MyEventSchema.statics.getFieldsForSearch = function() {
{field: 'details', type: tools.FieldType.string}];
};
MyEventSchema.statics.executeQueryTable = function(idapp, params) {
MyEventSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
if (tools.INITDB_FIRSTIME) {

View File

@@ -42,6 +42,9 @@ const MyGoodSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
numLevel: {
type: Number,
default: 0,
@@ -132,7 +135,7 @@ MyGoodSchema.statics.getFieldsLastForSearch = function() {
};
MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -150,6 +153,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
idStatusGood: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
otherfilters: 1,
@@ -165,6 +169,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -172,7 +177,7 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
@@ -238,6 +243,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -255,6 +261,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -291,6 +298,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -308,6 +316,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -344,6 +353,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -361,6 +371,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -397,6 +408,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -414,6 +426,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -450,6 +463,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
@@ -467,6 +481,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -106,7 +106,7 @@ MyGroupSchema.statics.getFieldsForSearch = function() {
return [{field: 'descr', type: tools.FieldType.string}];
};
MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
const { User } = require('./user');
@@ -119,7 +119,7 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params) {
}
}
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyGroupSchema.pre('save', async function(next) {
@@ -149,6 +149,18 @@ MyGroupSchema.statics.findAllIdApp = async function(idapp) {
return await MyGroup.find(myfind);
};
MyGroupSchema.statics.findAllGroups = async function(idapp) {
const whatToShow = this.getWhatToShow(idapp, '');
return await MyGroup.find({
idapp,
$or: [
{deleted: {$exists: false}},
{deleted: {$exists: true, $eq: false}}],
}, whatToShow);
};
// Rimuovo la Richiesta del Gruppo
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {

View File

@@ -67,6 +67,9 @@ const MyHospSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
descr: {
type: String,
},
@@ -134,7 +137,7 @@ MyHospSchema.statics.getFieldsLastForSearch = function() {
];
};
MyHospSchema.statics.executeQueryTable = function(idapp, params) {
MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -154,6 +157,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -165,6 +169,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -172,7 +177,7 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyHospSchema.statics.getMyRecById = function(idapp, id) {
@@ -238,6 +243,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -251,6 +257,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -287,6 +294,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -300,6 +308,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -336,6 +345,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -349,6 +359,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -385,6 +396,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -398,6 +410,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -434,6 +447,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
@@ -447,6 +461,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},

View File

@@ -125,9 +125,9 @@ MyPageSchema.statics.getFieldsForSearch = function () {
{ field: 'content', type: tools.FieldType.string }]
};
MyPageSchema.statics.executeQueryTable = function (idapp, params) {
MyPageSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MyPageSchema.statics.findAllIdApp = async function (idapp) {

View File

@@ -48,6 +48,9 @@ const MySkillSchema = new Schema({
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_GROUPS_FOLLOW
},
numLevel: {
type: Number,
default: 0,
@@ -134,8 +137,7 @@ MySkillSchema.statics.getFieldsLastForSearch = function() {
];
};
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -153,6 +155,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
idStatusSkill: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
@@ -167,6 +170,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
name: 1,
surname: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -174,7 +178,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
params = {...params, ...otherparams};
return tools.executeQueryTable(this, idapp, params);
return tools.executeQueryTable(this, idapp, params, user);
};
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
@@ -240,6 +244,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -256,6 +261,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -292,6 +298,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -308,6 +315,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -344,6 +352,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -360,6 +369,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -398,6 +408,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -414,6 +425,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -450,6 +462,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
@@ -466,6 +479,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
},
},
@@ -483,7 +497,6 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
};
const MySkill = mongoose.model('MySkill', MySkillSchema);
module.exports = {MySkill};

View File

@@ -1345,6 +1345,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
@@ -1378,6 +1379,7 @@ UserSchema.statics.getUserProfileByUsername = async function(
verified_by_aportador: 1,
notask_verif: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.teleg_id': 1,
@@ -1794,6 +1796,7 @@ function getWhatToShow(idapp, username) {
verified_by_aportador: 1,
notask_verif: 1,
'profile.nationality': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
'profile.biografia': 1,
'profile.username_telegram': 1,

View File

@@ -1073,6 +1073,7 @@ function load(req, res, version) {
let sectorgoods = SectorGood.findAllIdApp(idapp);
let catgrps = CatGrp.findAllIdApp(idapp);
let site = Site.findAllIdApp(idapp);
let mygroups = MyGroup.findAllGroups(idapp);
// let cities = City.findAllIdApp(idapp);
let provinces = Province.findAllIdApp(idapp);
let cart = null;
@@ -1138,6 +1139,7 @@ function load(req, res, version) {
sectorgoods,
goods,
site,
mygroups,
]).then((arrdata) => {
// console.table(arrdata);
let myuser = req.user;
@@ -1216,6 +1218,7 @@ function load(req, res, version) {
sectorgoods: arrdata[33],
goods: arrdata[34],
site: arrdata[35],
mygroups: arrdata[36],
});
}

View File

@@ -35,7 +35,7 @@ async function sendNotif(res, idapp, user, recmsg) {
// Read from the operator table first
let emaildest = await Operator.getEmailByUsername(recmsg.dest.idapp, recmsg.dest.username);
if (emaildest === '')
if (!emaildest)
emaildest = await User.getEmailByUsername(recmsg.dest.idapp, recmsg.dest.username);
console.log('emaildest', emaildest);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -235,7 +235,6 @@ router.post('/', async (req, res) => {
user.aportador_solidario = await User.getRealUsernameByUsername(user.idapp, user.aportador_solidario);
}
if (!id_aportador && tools.getAskToVerifyReg(body.idapp)) {
// Si sta tentando di registrare una persona sotto che non corrisponde!
let msg = 'Il link di registrazione non sembra risultare valido.<br>invitante: ' +
@@ -383,19 +382,24 @@ router.post('/profile', authenticate, (req, res) => {
//++Todo: controlla che tipo di dati ha il permesso di leggere
return User.getUserProfileByUsername(idapp, username, req.user.username,
false, req.user.perm).
then((ris) => {
try {
return User.getUserProfileByUsername(idapp, username, req.user.username,
false, req.user.perm).
then((ris) => {
return User.getFriendsByUsername(idapp, req.user.username).
then((friends) => {
res.send({user: ris, friends});
});
return User.getFriendsByUsername(idapp, req.user.username).
then((friends) => {
res.send({user: ris, friends});
});
}).catch((e) => {
tools.mylog('ERRORE IN Profile: ' + e.message);
res.status(400).send();
});
}).catch((e) => {
tools.mylog('ERRORE IN Profile: ' + e.message);
res.status(400).send();
});
} catch (e) {
tools.mylogserr('Error profile: ', e);
res.status(400).send();
}
});
@@ -1105,9 +1109,9 @@ router.post('/mgt', authenticate, async (req, res) => {
locale = req.body.locale;
try {
const {nummsgsent, numrec } = await telegrambot.sendMsgFromSiteToBotTelegram(idapp, req.user, mydata);
const {nummsgsent, numrec} = await telegrambot.sendMsgFromSiteToBotTelegram(idapp, req.user, mydata);
return res.send({numrec, nummsgsent });
return res.send({numrec, nummsgsent});
} catch (e) {
res.status(400).send();

View File

@@ -837,7 +837,7 @@ module.exports = {
const telegrambot = require('../telegram/telegrambot');
const user = await User.findOne({idapp, username}, {_id: 1, username:1, lang: 1}).lean();
const user = await User.findOne({idapp, username}, {_id: 1, username: 1, lang: 1}).lean();
if (!user)
return;
@@ -892,7 +892,7 @@ module.exports = {
const idtelegram = await User.TelegIdById(idapp, userId);
const msgteleg = objmsg.descr + (msgextrateleg ? '\n' + msgextrateleg : '')
const msgteleg = objmsg.descr + (msgextrateleg ? '\n' + msgextrateleg : '');
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, msgteleg);
}
},
@@ -950,7 +950,8 @@ module.exports = {
objmsg.tag = 'reqgroups';
sendnotif = false; // non lo rimandare 2 volte !
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname, group._id);
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname,
group._id);
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
objmsg.descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang),
@@ -1366,7 +1367,7 @@ module.exports = {
return query;
},
getQueryTable: function(idapp, params) {
getQueryTable: function(idapp, params, user) {
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number');
@@ -1431,7 +1432,7 @@ module.exports = {
filtriadded.push({verified_email: false});
if (params.filterand.includes(shared_consts.FILTER_USER_NO_VERIFIED_APORTADOR))
filtriadded.push({
verified_by_aportador: {$exists: false},
verified_by_aportador: {$exists: false},
});
if (params.filterand.includes(shared_consts.FILTER_USER_WITHOUT_USERNAME_TELEGRAM))
filtriadded.push({
@@ -1515,6 +1516,7 @@ module.exports = {
}
if (params.filtercustom) {
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['userId']) {
myfilter['userId'] = ObjectID(myfilter['userId']);
@@ -1524,13 +1526,15 @@ module.exports = {
} else if (myfilter['dateTimeStart']) {
const gte = myfilter['dateTimeStart'].$gte;
const lte = myfilter['dateTimeStart'].$lte;
let condition = {
condition = {
dateTimeStart: {
$gte: new Date(gte),
$lte: new Date(lte),
},
};
filtriadded.push(condition);
} else if (myfilter.hasOwnProperty('pub_to_share')) {
// non aggiungere niente
} else {
filtriadded.push(myfilter);
}
@@ -1541,7 +1545,7 @@ module.exports = {
for (let ind = 0; ind < params.filter_gte.length; ind++) {
for (const [key, value] of Object.entries(params.filter_gte[ind])) {
if (value > 0) {
let condition = {}
let condition = {};
condition[key] = {$gte: value};
filtriadded.push(condition);
}
@@ -1671,6 +1675,38 @@ module.exports = {
query.push({$match: {$and: params.filtersearch2}});
}
}
if (params.filtercustom) {
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_GROUPS_FOLLOW) {
let arraygroups = [];
if (user && user.profile.mygroups) {
arraygroups = user.profile.mygroups.map(rec => rec.groupname);
}
// prendere i gruppi dell'utente
// Cerca tra i gruppi di ogni record, se combaciano almeno 1
condition = {
'profile.mygroups':
{
$elemMatch: {
groupname: {$in: arraygroups},
},
},
};
query.push({$match: {$and: [condition]}});
}
}
}
if (params.filtersearch3or) {
if (params.filtersearch3or.length > 0) {
query.push({$match: {$or: params.filtersearch3or}});
@@ -1722,8 +1758,8 @@ module.exports = {
},
async executeQueryTable(mythistable, idapp, params) {
let query = this.getQueryTable(idapp, params);
async executeQueryTable(mythistable, idapp, params, user) {
let query = this.getQueryTable(idapp, params, user);
try {
// console.log('query', query);
@@ -2784,23 +2820,23 @@ module.exports = {
if (u_tg) {
msg += `<br>Profilo su Telegram [${name_tg} ${surname_tg}]:<br>https://t.me/${u_tg}`;
}
}catch (e) {
} catch (e) {
console.error('getUserInfoMsg', e);
}
return msg;
},
getlinkRequestNewPassword: function (idapp, email, tokenforgot) {
const strlinkreg = this.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD + `?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
getlinkRequestNewPassword: function(idapp, email, tokenforgot) {
const strlinkreg = this.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD +
`?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
return strlinkreg;
},
execScript: function(idapp, msg, script, testo) {
const { exec } = require("child_process");
const {exec} = require('child_process');
const telegrambot = require('../telegram/telegrambot');
const idchat = msg.chat.id;
console.log(testo + ' (' + script + ')');
@@ -2821,6 +2857,6 @@ module.exports = {
// console.log(` ... stdout: ${stdout}`);
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, stdout);
});
}
},
};

View File

@@ -63,6 +63,11 @@ module.exports = {
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
PUBTOSHARE: {
ALL: 0,
ONLY_GROUPS_FOLLOW: 1,
},
TAB_COUNTRY: 'countries',
TAB_PHONES: 'phones',
TAB_SETTINGS: 'settings',