- Invia Ris a e Ricevi Ris
- Tutorial Guidato Passi da Compiere - Provincia in cui vivi - Policy aggiornata
This commit is contained in:
@@ -47,6 +47,10 @@ const CircuitSchema = new Schema({
|
|||||||
{
|
{
|
||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
|
strProv:
|
||||||
|
{
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
pub_to_share: {
|
pub_to_share: {
|
||||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||||
},
|
},
|
||||||
@@ -225,7 +229,7 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
|
|
||||||
const whatToShow = this.getWhatToShow(idapp, '');
|
const whatToShow = this.getWhatToShow(idapp, '');
|
||||||
|
|
||||||
return await Circuit.find(myfind, whatToShow).sort({status: -1, numMembers: -1, name: 1});
|
return await Circuit.find(myfind, whatToShow).sort({ status: -1, numMembers: -1, name: 1 });
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||||
@@ -271,6 +275,7 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
|||||||
valuta_per_euro: 1,
|
valuta_per_euro: 1,
|
||||||
symbol: 1,
|
symbol: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
|
strProv: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
color: 1,
|
color: 1,
|
||||||
@@ -332,6 +337,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
|||||||
symbol: 1,
|
symbol: 1,
|
||||||
color: 1,
|
color: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
|
strProv: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
visibility: 1,
|
visibility: 1,
|
||||||
abbrev: 1,
|
abbrev: 1,
|
||||||
@@ -370,14 +376,14 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}).sort({status: -1, numMembers: -1, name: 1}).lean();
|
}).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||||
|
|
||||||
let listcircuits = await Circuit.find({
|
let listcircuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).sort({status: -1, numMembers: -1, name: 1}).lean();
|
}, whatToShow_Unknown).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||||
|
|
||||||
let asked_circuits = await Circuit.find({
|
let asked_circuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -387,7 +393,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).sort({status: -1}).lean();
|
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||||
|
|
||||||
let refused_circuits = await Circuit.find({
|
let refused_circuits = await Circuit.find({
|
||||||
idapp,
|
idapp,
|
||||||
@@ -397,7 +403,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, whatToShow_Unknown).sort({status: -1}).lean();
|
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listcircuits,
|
listcircuits,
|
||||||
@@ -687,7 +693,7 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
|||||||
extrarec.saldoDest = accountdestTable.saldo;
|
extrarec.saldoDest = accountdestTable.saldo;
|
||||||
|
|
||||||
let orig = usernameOrig + (extrarec.grouporig ? extrarec.grouporig : '') + (extrarec.contoComOrig ? extrarec.contoComOrig : '');
|
let orig = usernameOrig + (extrarec.grouporig ? extrarec.grouporig : '') + (extrarec.contoComOrig ? extrarec.contoComOrig : '');
|
||||||
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupDest ? extrarec.groupDest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
|
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupDest ? extrarec.groupDest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||||
|
|
||||||
ris.result = true;
|
ris.result = true;
|
||||||
let msg = 'Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal + `] [Saldo ${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + ` [Saldo ${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
|
let msg = 'Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal + `] [Saldo ${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + ` [Saldo ${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
|
||||||
@@ -835,6 +841,25 @@ CircuitSchema.statics.getListAdminsByCircuitPath = async function (idapp, circui
|
|||||||
|
|
||||||
|
|
||||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||||
|
CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
|
||||||
|
const { City } = require('../models/city');
|
||||||
|
|
||||||
|
const arrcircuits = await Circuit.find({ idapp }).lean();
|
||||||
|
try {
|
||||||
|
for (const rec of arrcircuits) {
|
||||||
|
let recstrProv = await City.findOne({ _id: rec.idCity[0] });
|
||||||
|
if (recstrProv) {
|
||||||
|
let objProv = {}
|
||||||
|
objProv['strProv'] = recstrProv.prov;
|
||||||
|
await Circuit.updateOne({ _id: rec._id }, { $set: objProv });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
||||||
|
|
||||||
ris = await Circuit.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
ris = await Circuit.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ const MyGroupSchema = new Schema({
|
|||||||
circuitname: { type: String },
|
circuitname: { type: String },
|
||||||
date: { type: Date },
|
date: { type: Date },
|
||||||
}],
|
}],
|
||||||
|
lastdate_reqRisGroup: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
MyGroupSchema.statics.getFieldsForSearch = function () {
|
MyGroupSchema.statics.getFieldsForSearch = function () {
|
||||||
@@ -230,7 +233,7 @@ MyGroupSchema.statics.getListAdminsByGroupName = async function (idapp, groupnam
|
|||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
}, {admins: 1}).lean();
|
}, { admins: 1 }).lean();
|
||||||
|
|
||||||
return arr && arr.admins ? arr.admins : [];
|
return arr && arr.admins ? arr.admins : [];
|
||||||
|
|
||||||
@@ -259,6 +262,7 @@ MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
|||||||
date_created: 1,
|
date_created: 1,
|
||||||
date_updated: 1,
|
date_updated: 1,
|
||||||
mycircuits: 1,
|
mycircuits: 1,
|
||||||
|
lastdate_reqRisGroup: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -276,6 +280,7 @@ MyGroupSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
|||||||
date_created: 1,
|
date_created: 1,
|
||||||
date_updated: 1,
|
date_updated: 1,
|
||||||
mycircuits: 1,
|
mycircuits: 1,
|
||||||
|
lastdate_reqRisGroup: 1,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -496,10 +501,14 @@ MyGroupSchema.statics.ifCircuitAlreadyInGroup = async function (idapp, groupname
|
|||||||
// aggiungo il Circuito all'interno del Gruppo
|
// aggiungo il Circuito all'interno del Gruppo
|
||||||
MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
||||||
return await this.updateOne({ idapp, groupname },
|
return await this.updateOne({ idapp, groupname },
|
||||||
{ $push: { 'mycircuits': {
|
{
|
||||||
circuitname,
|
$push: {
|
||||||
date: new Date(),
|
'mycircuits': {
|
||||||
} } });
|
circuitname,
|
||||||
|
date: new Date(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -510,6 +519,117 @@ MyGroupSchema.statics.removeCircuitFromGroup = async function (idapp, groupname,
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MyGroupSchema.statics.getQueryReceiveRISGroups = function (idapp, hours) {
|
||||||
|
|
||||||
|
const query = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
idapp,
|
||||||
|
'lastdate_reqRisGroup': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||||
|
$or: [
|
||||||
|
{ deleted: { $exists: false } },
|
||||||
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group:
|
||||||
|
{
|
||||||
|
_id: "$groupname",
|
||||||
|
count: {
|
||||||
|
$sum: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ $sort: { 'lastdate_reqRisGroup': -1 } },
|
||||||
|
{ $limit: 30 },
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "mygroups",
|
||||||
|
let: {
|
||||||
|
groupname: "$_id",
|
||||||
|
idapp,
|
||||||
|
},
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$expr: {
|
||||||
|
$and: [
|
||||||
|
{
|
||||||
|
$eq: [
|
||||||
|
"$$groupname",
|
||||||
|
"$groupname",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$eq: [
|
||||||
|
"$$idapp",
|
||||||
|
"$idapp",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: "mygroup",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ $unwind: "$mygroup" },
|
||||||
|
{
|
||||||
|
$replaceRoot: {
|
||||||
|
newRoot: {
|
||||||
|
$mergeObjects: ["$mygroup", "$$ROOT"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
groupname: 1,
|
||||||
|
title: 1,
|
||||||
|
descr: 1,
|
||||||
|
visibility: 1,
|
||||||
|
idCatGrp: 1,
|
||||||
|
userId: 1,
|
||||||
|
photos: 1,
|
||||||
|
idCity: 1,
|
||||||
|
website: 1,
|
||||||
|
link_telegram: 1,
|
||||||
|
note: 1,
|
||||||
|
admins: 1,
|
||||||
|
blocked: 1,
|
||||||
|
req_users: 1,
|
||||||
|
createdBy: 1,
|
||||||
|
date_created: 1,
|
||||||
|
date_updated: 1,
|
||||||
|
lastdate_reqRisGroup: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return query;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MyGroupSchema.statics.getReceiveRISGroups = async function (idapp) {
|
||||||
|
|
||||||
|
return await this.aggregate(this.getQueryReceiveRISGroups(idapp, 8)).then(ris => {
|
||||||
|
return ris;
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||||
|
|
||||||
|
return await this.findOneAndUpdate({
|
||||||
|
idapp, groupname,
|
||||||
|
},
|
||||||
|
{ $set: { 'lastdate_reqRisGroup': new Date() } }, { new: false }).lean().then((record) => {
|
||||||
|
return !!record;
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ ProvinceSchema.statics.executeQueryPickup = async function(idapp, params) {
|
|||||||
ProvinceSchema.statics.findAllIdApp = async function(idapp) {
|
ProvinceSchema.statics.findAllIdApp = async function(idapp) {
|
||||||
const myfind = {};
|
const myfind = {};
|
||||||
|
|
||||||
return Province.find(myfind).sort({prov: 1});
|
return Province.find(myfind).sort({descr: 1});
|
||||||
};
|
};
|
||||||
|
|
||||||
const Province = mongoose.model('Province', ProvinceSchema);
|
const Province = mongoose.model('Province', ProvinceSchema);
|
||||||
|
|||||||
@@ -398,7 +398,12 @@ const UserSchema = new mongoose.Schema({
|
|||||||
circuitname: { type: String },
|
circuitname: { type: String },
|
||||||
date: { type: Date },
|
date: { type: Date },
|
||||||
}],
|
}],
|
||||||
|
last_circuitpath: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
lastdate_reqRis: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
notifs: [
|
notifs: [
|
||||||
{
|
{
|
||||||
_id: false,
|
_id: false,
|
||||||
@@ -433,6 +438,12 @@ const UserSchema = new mongoose.Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
trim: true,
|
trim: true,
|
||||||
},
|
},
|
||||||
|
stepTutorial: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
noNameSurname: {
|
||||||
|
type: Boolean,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3764,6 +3775,7 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
|
date_reg: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
}).sort({ lasttimeonline: -1 }).limit(lastn).then((arr) => {
|
}).sort({ lasttimeonline: -1 }).limit(lastn).then((arr) => {
|
||||||
@@ -3790,6 +3802,7 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
|
date_reg: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
}).sort({ date_tokenreg: -1 }).limit(lastn).then((arr) => {
|
}).sort({ date_tokenreg: -1 }).limit(lastn).then((arr) => {
|
||||||
@@ -3822,6 +3835,16 @@ UserSchema.statics.getBestStretteDiManoUsers = async function (idapp) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.getReceiveRISUsers = async function (idapp) {
|
||||||
|
const User = this;
|
||||||
|
|
||||||
|
return await User.aggregate(User.getQueryReceiveRISUsers(idapp, 8)).then(ris => {
|
||||||
|
// console.table(ris);
|
||||||
|
return ris;
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.checkUser = async function (idapp, username) {
|
UserSchema.statics.checkUser = async function (idapp, username) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
@@ -4020,8 +4043,10 @@ UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
|
date_reg: 1,
|
||||||
idapp: 1,
|
idapp: 1,
|
||||||
"profile.img": 1,
|
"profile.img": 1,
|
||||||
|
'profile.mycircuits': 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -4110,6 +4135,92 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
|
date_reg: 1,
|
||||||
|
idapp: 1,
|
||||||
|
"profile.img": 1,
|
||||||
|
'profile.handshake': 1,
|
||||||
|
'profile.mycircuits': 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return query;
|
||||||
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.getQueryReceiveRISUsers = function (idapp, hours) {
|
||||||
|
|
||||||
|
const query = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
idapp,
|
||||||
|
'profile.lastdate_reqRis': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||||
|
$or: [
|
||||||
|
{ deleted: { $exists: false } },
|
||||||
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group:
|
||||||
|
{
|
||||||
|
_id: "$username",
|
||||||
|
count: {
|
||||||
|
$sum: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ $sort: { 'profile.lastdate_reqRis': -1 } },
|
||||||
|
{ $limit: 30 },
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "users",
|
||||||
|
let: {
|
||||||
|
username: "$_id",
|
||||||
|
idapp,
|
||||||
|
},
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$expr: {
|
||||||
|
$and: [
|
||||||
|
{
|
||||||
|
$eq: [
|
||||||
|
"$$username",
|
||||||
|
"$username",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$eq: [
|
||||||
|
"$$idapp",
|
||||||
|
"$idapp",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: "user",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ $unwind: "$user" },
|
||||||
|
{
|
||||||
|
$replaceRoot: {
|
||||||
|
newRoot: {
|
||||||
|
$mergeObjects: ["$user", "$$ROOT"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
count: 1,
|
||||||
|
aportador_solidario: 1,
|
||||||
|
username: 1,
|
||||||
|
name: 1,
|
||||||
|
surname: 1,
|
||||||
|
lasttimeonline: 1,
|
||||||
|
'profile.lastdate_reqRis': 1,
|
||||||
|
'profile.mycircuits': 1,
|
||||||
|
date_reg: 1,
|
||||||
idapp: 1,
|
idapp: 1,
|
||||||
"profile.img": 1,
|
"profile.img": 1,
|
||||||
'profile.handshake': 1,
|
'profile.handshake': 1,
|
||||||
@@ -4184,7 +4295,7 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
|
|||||||
UserSchema.statics.calcnumRegUntilDay = async function (idapp) {
|
UserSchema.statics.calcnumRegUntilDay = async function (idapp) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
return await User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
return await User.aggregate(User.getnumRegNDays(idapp, 60)).then((arr) => {
|
||||||
return arr.reduce((sum, rec) => sum + rec.count, 0);
|
return arr.reduce((sum, rec) => sum + rec.count, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -4622,6 +4733,27 @@ UserSchema.statics.tooManyReqPassword = async function (idapp, email, set) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.setLastCircuitOpened = async function (idapp, username, circuitpath) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return await User.findOneAndUpdate({ idapp, username }, { $set: { 'profile.last_circuitpath': circuitpath } });
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.setReceiveRis = async function (idapp, username) {
|
||||||
|
const User = this;
|
||||||
|
|
||||||
|
return await User.findOneAndUpdate({
|
||||||
|
idapp, username,
|
||||||
|
},
|
||||||
|
{ $set: { 'profile.lastdate_reqRis': new Date() } }, { new: false }).lean().then((record) => {
|
||||||
|
return !!record;
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp);
|
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp);
|
||||||
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
|
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
|
||||||
|
|
||||||
|
await User.setLastCircuitOpened(idapp, req.user.username, path);
|
||||||
|
|
||||||
res.send({ circuit: data, users_in_circuit, arrrecnotif, useraccounts });
|
res.send({ circuit: data, users_in_circuit, arrrecnotif, useraccounts });
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
|
const { MyGroup } = require('../models/mygroup');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', false)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
@@ -50,6 +52,8 @@ router.post('/load', async (req, res) => {
|
|||||||
lastsonline: await User.getLastOnlineUsers(idapp),
|
lastsonline: await User.getLastOnlineUsers(idapp),
|
||||||
lastssharedlink: await User.getLastSharedLink(idapp),
|
lastssharedlink: await User.getLastSharedLink(idapp),
|
||||||
diffusorilist: await User.getDiffusoriUsers(idapp),
|
diffusorilist: await User.getDiffusoriUsers(idapp),
|
||||||
|
receiveRislist: await User.getReceiveRISUsers(idapp),
|
||||||
|
receiveRislistgroup: await MyGroup.getReceiveRISGroups(idapp),
|
||||||
strettelist: await User.getBestStretteDiManoUsers(idapp),
|
strettelist: await User.getBestStretteDiManoUsers(idapp),
|
||||||
checkuser: await User.checkUser(idapp, username),
|
checkuser: await User.checkUser(idapp, username),
|
||||||
// navi_partite: await Nave.getNaviPartite(idapp),
|
// navi_partite: await Nave.getNaviPartite(idapp),
|
||||||
|
|||||||
@@ -396,6 +396,38 @@ router.patch('/:id', authenticate, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/receiveris', authenticate, (req, res) => {
|
||||||
|
const username = req.user ? req.user.username : '';
|
||||||
|
const groupname = req.body.groupname;
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!username)
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR });
|
||||||
|
|
||||||
|
if (groupname) {
|
||||||
|
return MyGroup.setReceiveRisGroup(idapp, groupname)
|
||||||
|
.then(risult => {
|
||||||
|
res.send({ code: server_constants.RIS_CODE_OK });
|
||||||
|
}).catch((err) => {
|
||||||
|
tools.mylog('ERRORE IN receiveris: ' + err.message);
|
||||||
|
res.status(400).send();
|
||||||
|
});
|
||||||
|
} else if (username) {
|
||||||
|
return User.setReceiveRis(idapp, username)
|
||||||
|
.then(risult => {
|
||||||
|
res.send({ code: server_constants.RIS_CODE_OK });
|
||||||
|
}).catch((err) => {
|
||||||
|
tools.mylog('ERRORE IN receiveris: ' + err.message);
|
||||||
|
res.status(400).send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
res.status(400).send();
|
||||||
|
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
router.post('/profile', (req, res) => {
|
router.post('/profile', (req, res) => {
|
||||||
const usernameOrig = req.user ? req.user.username : '';
|
const usernameOrig = req.user ? req.user.username : '';
|
||||||
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
|
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
|
||||||
@@ -405,7 +437,6 @@ router.post('/profile', (req, res) => {
|
|||||||
|
|
||||||
//++Todo: controlla che tipo di dati ha il permesso di leggere
|
//++Todo: controlla che tipo di dati ha il permesso di leggere
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if ìs a Notif to read
|
// Check if ìs a Notif to read
|
||||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||||
@@ -1111,6 +1142,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
|
|
||||||
await Circuit.SetDefMinMaxCollettivi(idapp, mydata.valmin, mydata.valmax);
|
await Circuit.SetDefMinMaxCollettivi(idapp, mydata.valmin, mydata.valmax);
|
||||||
|
|
||||||
|
} else if (mydata.dbop === 'setstrProvByIdCityCircuits') {
|
||||||
|
|
||||||
|
await Circuit.setstrProvByIdCityCircuits(idapp);
|
||||||
|
|
||||||
} else if (mydata.dbop === 'CreateAccountCircuits') {
|
} else if (mydata.dbop === 'CreateAccountCircuits') {
|
||||||
|
|
||||||
const allcirc = await Circuit.find({ idapp });
|
const allcirc = await Circuit.find({ idapp });
|
||||||
@@ -1205,6 +1240,12 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
|||||||
|
|
||||||
ris = await populate.popolaTabelleNuove();
|
ris = await populate.popolaTabelleNuove();
|
||||||
|
|
||||||
|
} else if (mydata.dbop === 'saveStepTut') {
|
||||||
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
|
{ $set: { 'profile.stepTutorial': mydata.value } });
|
||||||
|
} else if (mydata.dbop === 'noNameSurname') {
|
||||||
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
|
{ $set: { 'profile.noNameSurname': mydata.value } });
|
||||||
} else if (mydata.dbop === 'ricreaTabCitiesProvinces') {
|
} else if (mydata.dbop === 'ricreaTabCitiesProvinces') {
|
||||||
|
|
||||||
// Svuota e Ricrea
|
// Svuota e Ricrea
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ module.exports = {
|
|||||||
|
|
||||||
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
||||||
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
|
TABLES_INSERT_ALMOST_ONE_TO_ENABLE_CIRCUIT: ['myskills', 'myhosps', 'mygoods'],
|
||||||
//++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC
|
//++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC
|
||||||
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||||
|
|||||||
Reference in New Issue
Block a user