correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle...
This commit is contained in:
@@ -141,7 +141,7 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
|
||||
{ $group: { _id: null, count: { $sum: '$saldo' } } }
|
||||
];
|
||||
|
||||
ris = await Account.aggregate(aggr1);
|
||||
const ris = await Account.aggregate(aggr1);
|
||||
|
||||
return ris ? ris[0].count : 0;
|
||||
|
||||
@@ -340,6 +340,7 @@ AccountSchema.statics.createAccount = async function (idapp, username, circuitNa
|
||||
};
|
||||
|
||||
AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
@@ -391,17 +392,25 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
},
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
const ris = await this.aggregate(aggr1);
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
// console.log('1 - INIZIA getUserAccounts ')
|
||||
// console.log(aggr1);
|
||||
|
||||
if (ris) {
|
||||
for (const account of ris) {
|
||||
try {
|
||||
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
|
||||
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
account.saldo -= saldopending;
|
||||
account.totTransato = account.totTransato || 0;
|
||||
//++OTTIMIZZARE QUESTA PARTE ! (CON UNA QUERY...)
|
||||
// console.log(' 1B - PENDIND... ')
|
||||
|
||||
let pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
|
||||
let saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
if (saldopending !== 0) {
|
||||
account.saldo -= saldopending;
|
||||
account.totTransato = account.totTransato || 0;
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('getUserAccounts 1) ', e);
|
||||
}
|
||||
@@ -409,6 +418,7 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(' 2 - FINE getUserAccounts LEN=', ris.length)
|
||||
return ris;
|
||||
} catch (e) {
|
||||
console.error('getUserAccounts', e);
|
||||
@@ -470,16 +480,20 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
},
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
const ris = await this.aggregate(aggr1);
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
if (ris) {
|
||||
// tools.startTimeLog('Query Pending')
|
||||
for (const account of ris) {
|
||||
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, '', account.circuit.name, groupname);
|
||||
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.result.extrarec.qty, 0);
|
||||
account.saldo -= saldopending;
|
||||
if (saldopending) {
|
||||
account.saldo -= saldopending;
|
||||
}
|
||||
}
|
||||
// tools.endTimeLog('Query Pending')
|
||||
}
|
||||
|
||||
return ris;
|
||||
@@ -493,7 +507,7 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
|
||||
const ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -508,7 +522,7 @@ AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valma
|
||||
AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||
const ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -524,7 +538,7 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax
|
||||
const Account = this;
|
||||
|
||||
if (circuitId) {
|
||||
ris = await Account.updateMany({ idapp, circuitId, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
const ris = await Account.updateMany({ idapp, circuitId, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -533,7 +547,7 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -556,12 +570,12 @@ AccountSchema.statics.updateFido = async function (idapp, username, circuitId, f
|
||||
};
|
||||
|
||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||
const account = await Account.findOne({_id: id}).lean();
|
||||
const account = await Account.findOne({ _id: id }).lean();
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
if (account) {
|
||||
const circuit = await Circuit.findOne({_id: account.circuitId}).lean();
|
||||
const circuit = await Circuit.findOne({ _id: account.circuitId }).lean();
|
||||
if (circuit) {
|
||||
return circuit.admins.findIndex((admin) => admin.username === username) >= 0;
|
||||
}
|
||||
|
||||
@@ -642,7 +642,7 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
},
|
||||
},
|
||||
};
|
||||
ris = await User.updateOne({ idapp, username: extrarec.dest }, update);
|
||||
const ris = await User.updateOne({ idapp, username: extrarec.dest }, update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +865,7 @@ CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
|
||||
|
||||
CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
|
||||
|
||||
ris = await Circuit.updateMany({ idapp },
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -878,7 +878,7 @@ CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
|
||||
|
||||
CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
|
||||
|
||||
ris = await Circuit.updateMany({ idapp },
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -893,7 +893,7 @@ CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
|
||||
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
|
||||
|
||||
if (circuitId) {
|
||||
ris = await Circuit.updateOne({ _id: circuitId },
|
||||
const ris = await Circuit.updateOne({ _id: circuitId },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -903,7 +903,7 @@ CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, val
|
||||
});
|
||||
} else {
|
||||
|
||||
ris = await Circuit.updateMany({ idapp },
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -1065,7 +1065,7 @@ CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, usernam
|
||||
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax, circuitId) {
|
||||
|
||||
if (circuitId) {
|
||||
ris = await Circuit.updateOne({ _id: circuitId },
|
||||
const ris = await Circuit.updateOne({ _id: circuitId },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
@@ -1074,7 +1074,7 @@ CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, va
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ris = await Circuit.updateMany({ idapp },
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
|
||||
@@ -208,6 +208,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
|
||||
@@ -9,6 +9,8 @@ const tools = require('../tools/general');
|
||||
const { ObjectID } = require('mongodb');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const tableModel = shared_consts.TABLES_MYBACHECAS;
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
@@ -17,103 +19,106 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyBachecaSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
groupname: { type: String },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
dateTimeStart: {
|
||||
type: Date,
|
||||
},
|
||||
dateTimeEnd: {
|
||||
type: Date,
|
||||
},
|
||||
organisedBy: {
|
||||
type: String
|
||||
},
|
||||
contact_phone: {
|
||||
type: String
|
||||
},
|
||||
contact_telegram: {
|
||||
type: String
|
||||
},
|
||||
address: {
|
||||
type: String,
|
||||
},
|
||||
min_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
max_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
contribstr: {
|
||||
type: String,
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
groupname: { type: String },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
dateTimeStart: {
|
||||
type: Date,
|
||||
},
|
||||
dateTimeEnd: {
|
||||
type: Date,
|
||||
},
|
||||
organisedBy: {
|
||||
type: String
|
||||
},
|
||||
contact_phone: {
|
||||
type: String
|
||||
},
|
||||
contact_telegram: {
|
||||
type: String
|
||||
},
|
||||
address: {
|
||||
type: String,
|
||||
},
|
||||
min_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
max_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
contribstr: {
|
||||
type: String,
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyBachecaSchema.pre('save', async function (next) {
|
||||
|
||||
@@ -6,6 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
@@ -16,76 +18,79 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyGoodSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSectorGood: {
|
||||
type: Number,
|
||||
},
|
||||
idGood: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idShipping: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSectorGood: {
|
||||
type: Number,
|
||||
},
|
||||
idGood: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idShipping: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
otherfilters: [{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
otherfilters: [{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MyGood
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MyGood
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyGoodSchema.pre('save', async function (next) {
|
||||
@@ -155,8 +160,8 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
|
||||
let query = [
|
||||
{
|
||||
'$match':
|
||||
myparsid,
|
||||
'$match':
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
@@ -309,7 +314,7 @@ MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, {...toadd}];
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MyGood.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
@@ -338,7 +343,7 @@ MyGoodSchema.statics.getProject = function () {
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
|
||||
}
|
||||
|
||||
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||
|
||||
@@ -6,6 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
@@ -15,81 +17,84 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyHospSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyHospSchema.pre('save', async function (next) {
|
||||
@@ -154,7 +159,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||
let query = [
|
||||
{
|
||||
'$match':
|
||||
myparsid,
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
@@ -306,7 +311,7 @@ MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, {...toadd}];
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MyHosp.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
@@ -337,7 +342,7 @@ MyHospSchema.statics.getProject = function () {
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,98 +6,104 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const MySkillSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
const MySkillSchema = new Schema(
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
/*idSubSkill: [
|
||||
{
|
||||
type: Number,
|
||||
default: 0,
|
||||
}],
|
||||
|
||||
*/
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYSKILL
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
/*idSubSkill: [
|
||||
{
|
||||
type: Number,
|
||||
default: 0,
|
||||
}],
|
||||
|
||||
*/
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYSKILL
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MySkillSchema.index({ 'idapp': 1 });
|
||||
|
||||
|
||||
MySkillSchema.pre('save', async function(next) {
|
||||
MySkillSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
@@ -106,12 +112,12 @@ MySkillSchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MySkillSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MySkill = this;
|
||||
|
||||
const query = [
|
||||
{$match: {idapp}},
|
||||
{$sort: {descr: 1}},
|
||||
{ $match: { idapp } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return await MySkill.aggregate(query).then((arrrec) => {
|
||||
@@ -120,20 +126,20 @@ MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsForSearch = function() {
|
||||
MySkillSchema.statics.getFieldsForSearch = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsLastForSearch = function() {
|
||||
MySkillSchema.statics.getFieldsLastForSearch = function () {
|
||||
return [
|
||||
{field: 'note', type: tools.FieldType.string},
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{field: 'recSkill.descr', type: tools.FieldType.string},
|
||||
{field: 'myskill.descr', type: tools.FieldType.string},
|
||||
{ field: 'note', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
{ field: 'recSkill.descr', type: tools.FieldType.string },
|
||||
{ field: 'myskill.descr', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MySkillSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
@@ -148,12 +154,12 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
},
|
||||
};
|
||||
|
||||
params = {...params, ...otherparams};
|
||||
params = { ...params, ...otherparams };
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
|
||||
const MySkill = this;
|
||||
|
||||
let query = [
|
||||
@@ -314,7 +320,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, {...toadd}];
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MySkill.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
@@ -336,10 +342,10 @@ MySkillSchema.statics.getProject = function (proj_add2) {
|
||||
const proj_add = shared_consts.getProjectForAll(proj_add2)
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
|
||||
}
|
||||
|
||||
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const MySkill = this;
|
||||
|
||||
return MySkill.getMyRecById(idapp, id);
|
||||
@@ -348,4 +354,4 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
module.exports = {MySkill};
|
||||
module.exports = { MySkill };
|
||||
|
||||
@@ -48,16 +48,99 @@ const reactionSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
reactionSchema.statics.getFieldsForSearch = function() {
|
||||
return [
|
||||
{field: 'username', type: tools.FieldType.string}];
|
||||
reactionSchema.statics.getFieldsForReactions = function () {
|
||||
let reactionsField = {
|
||||
numseen: {
|
||||
type: Number,
|
||||
},
|
||||
numbook: {
|
||||
type: Number,
|
||||
},
|
||||
numfav: {
|
||||
type: Number,
|
||||
},
|
||||
numattend: {
|
||||
type: Number,
|
||||
},
|
||||
};
|
||||
|
||||
return reactionsField;
|
||||
};
|
||||
|
||||
reactionSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
reactionSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'username', type: tools.FieldType.string }];
|
||||
};
|
||||
|
||||
reactionSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
reactionSchema.statics.calcReactions = async function (idapp, id, tab) {
|
||||
|
||||
try {
|
||||
let myquerycountreaction = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
idrec: id,
|
||||
tab,
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
numseen: {
|
||||
$sum: {
|
||||
$cond: {
|
||||
if: { $ifNull: ["$seen", false] }, // Check if the field exists and is not null
|
||||
then: 1, // Increment count by 1 if the field exists
|
||||
else: 0, // Otherwise, keep the count unchanged
|
||||
}
|
||||
}
|
||||
},
|
||||
numfav: {
|
||||
$sum: {
|
||||
$cond: {
|
||||
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
|
||||
then: 1, // Increment count by 1 if the field exists
|
||||
else: 0, // Otherwise, keep the count unchanged
|
||||
}
|
||||
}
|
||||
},
|
||||
numbook: {
|
||||
$sum: {
|
||||
$cond: {
|
||||
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
|
||||
then: 1, // Increment count by 1 if the field exists
|
||||
else: 0, // Otherwise, keep the count unchanged
|
||||
}
|
||||
}
|
||||
},
|
||||
numattend: {
|
||||
$sum: {
|
||||
$cond: {
|
||||
if: { $ifNull: ["$attend", false] }, // Check if the field exists and is not null
|
||||
then: 1, // Increment count by 1 if the field exists
|
||||
else: 0, // Otherwise, keep the count unchanged
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return await Reaction.aggregate(myquerycountreaction)
|
||||
.then((ris) => {
|
||||
return ris ? ris[0] : null;
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Aggiungo il Favorite
|
||||
reactionSchema.statics.addFavorite = async function (req, idapp, username, id, tab) {
|
||||
@@ -94,11 +177,11 @@ reactionSchema.statics.addFavorite = async function (req, idapp, username, id, t
|
||||
|
||||
}
|
||||
|
||||
return {ris, ok};
|
||||
return { ris, ok };
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err addFavorite', e);
|
||||
return {ris: null, ok: 0};
|
||||
return { ris: null, ok: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,7 +194,7 @@ reactionSchema.statics.addSeen = async function (req, idapp, username, id, tab)
|
||||
return await myrec.save()
|
||||
.then((ris) => {
|
||||
// console.log('salvato proj!');
|
||||
return {ris, ok: ris ? 1 : 0};
|
||||
return { ris, ok: ris ? 1 : 0 };
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("Error addSeen", err.message);
|
||||
@@ -133,7 +216,7 @@ reactionSchema.statics.addBookmark = async function (req, idapp, username, id, t
|
||||
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, book: true });
|
||||
return await myrec.save()
|
||||
.then((ris) => {
|
||||
return {ris, ok: ris ? 1 : 0};
|
||||
return { ris, ok: ris ? 1 : 0 };
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("Error addBookmark", err.message);
|
||||
@@ -155,7 +238,7 @@ reactionSchema.statics.addAttend = async function (req, idapp, username, id, tab
|
||||
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, attend: true });
|
||||
return await myrec.save()
|
||||
.then((ris) => {
|
||||
return {ris, ok: ris ? 1 : 0};
|
||||
return { ris, ok: ris ? 1 : 0 };
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("Error addAttend", err.message);
|
||||
@@ -175,7 +258,7 @@ reactionSchema.statics.removeFavorite = async function (
|
||||
|
||||
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
|
||||
if (myrec) {
|
||||
return Reaction.updateOne({ _id: myrec._id}, {
|
||||
return Reaction.updateOne({ _id: myrec._id }, {
|
||||
$set: {
|
||||
fav: false,
|
||||
}
|
||||
@@ -193,7 +276,7 @@ reactionSchema.statics.removeBookmark = async function (
|
||||
|
||||
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
|
||||
if (myrec) {
|
||||
return Reaction.updateOne({ _id: myrec._id}, {
|
||||
return Reaction.updateOne({ _id: myrec._id }, {
|
||||
$set: {
|
||||
book: false,
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ const sendNotifSchema = new Schema({
|
||||
textaddTelegram: {
|
||||
type: String,
|
||||
},
|
||||
textcontent_Telegram: {
|
||||
type: String,
|
||||
},
|
||||
linkaddTelegram: {
|
||||
type: String,
|
||||
}
|
||||
@@ -145,7 +148,7 @@ sendNotifSchema.statics.getRecNotif = function (id) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp) {
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord) {
|
||||
const SendNotif = this;
|
||||
|
||||
if (!lastdataread)
|
||||
@@ -157,7 +160,7 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, l
|
||||
{ 'dest': username },
|
||||
{ 'datenotif': { $gt: new Date(lastdataread) } },
|
||||
],
|
||||
}).lean().sort({ datenotif: -1 }).then(async (arrnotif) => {
|
||||
}).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => {
|
||||
// console.log('arrnotif', arrnotif.length);
|
||||
|
||||
return this.compileOtherFields(arrnotif);
|
||||
@@ -172,6 +175,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
|
||||
const numchars = 80;
|
||||
let newdescr = '';
|
||||
let newdescrtelegram = '';
|
||||
let mydescr = '';
|
||||
let myidrec = '';
|
||||
let sender = recnotif.sender ? recnotif.sender : '';
|
||||
@@ -205,7 +209,9 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
|
||||
tag = 'newevent';
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_NEW_REC) {
|
||||
newdescr = i18n.__('NEW_EVENT', userorig, mydescr);
|
||||
let eventobj = await tools.getEventForTelegram(recnotif.myrectableorig, mydescr, userorig);
|
||||
newdescr = eventobj.newdescr;
|
||||
newdescrtelegram = eventobj.newdescrtelegram;
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_SEND_MSG) {
|
||||
newdescr = i18n.__('EVENT_SEND_MSG', userorig, recnotif.title, recnotif.msg);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_ATTEND) {
|
||||
@@ -217,11 +223,12 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
else
|
||||
newdescr = i18n.__('SET_ATTEND', recnotif.paramsObj.username_action, recnotif.paramsObj.recObjCreator.descr);
|
||||
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
|
||||
tag = 'attend';
|
||||
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
|
||||
recnotif.linkaddTelegram = 'Vedi post';
|
||||
}
|
||||
recnotif.textcontent_Telegram = newdescrtelegram;
|
||||
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
|
||||
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
@@ -539,7 +546,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
tag = 'favorite';
|
||||
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
|
||||
recnotif.linkaddTelegram = 'Vedi post';
|
||||
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
|
||||
}
|
||||
|
||||
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
|
||||
@@ -898,9 +905,11 @@ sendNotifSchema.statics.createNewNotification = async function (req, res, params
|
||||
myrecnotif.idrec = rec._id;
|
||||
}
|
||||
|
||||
|
||||
myrecnotif.typedir = typedir;
|
||||
myrecnotif.typeid = typeid;
|
||||
|
||||
|
||||
await SendNotif.sendToTheDestinations(myrecnotif, req, res);
|
||||
|
||||
return true;
|
||||
@@ -972,24 +981,27 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
|
||||
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||
if (myrectableorig) {
|
||||
for (const city of myrectableorig.idCity) {
|
||||
const prov = await City.getProvinceByIdCity(city);
|
||||
arrprovinces.push(await City.getProvinceByIdCity(city));
|
||||
arrregions.push(await City.getRegionByIdCity(city));
|
||||
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
|
||||
if (myrecnotifpass.idrec && myrecnotifpass.idrec !== '0') {
|
||||
// const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||
const myrectableorig = await mytable.getCompleteRecord(myrecnotifpass.idapp, myrecnotifpass.idrec);
|
||||
if (myrectableorig) {
|
||||
for (const city of myrectableorig.idCity) {
|
||||
const prov = await City.getProvinceByIdCity(city);
|
||||
arrprovinces.push(await City.getProvinceByIdCity(city));
|
||||
arrregions.push(await City.getRegionByIdCity(city));
|
||||
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
|
||||
}
|
||||
|
||||
|
||||
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
||||
idSector = myrectableorig.idSectorGood;
|
||||
} else {
|
||||
idSector = myrectableorig.idSector;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
||||
idSector = myrectableorig.idSectorGood;
|
||||
} else {
|
||||
idSector = myrectableorig.idSector;
|
||||
}
|
||||
|
||||
myrecnotifpass.myrectableorig = myrectableorig;
|
||||
}
|
||||
myrecnotifpass.myrectableorig = myrectableorig;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2834,7 +2834,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
}
|
||||
|
||||
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
|
||||
|
||||
} else {
|
||||
outres.cansend = false;
|
||||
@@ -3105,27 +3105,34 @@ UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
idapp,
|
||||
'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean().then((rec) => {
|
||||
}).lean().then(async (rec) => {
|
||||
if (!rec) {
|
||||
// Cerca se esiste in quello salvato in precedenza:
|
||||
const recold = await User.findOne({
|
||||
idapp,
|
||||
'profile.teleg_id_old': teleg_id
|
||||
}).lean();
|
||||
if (recold && recold.profile.teleg_id_old === teleg_id) {
|
||||
// Riaggiorna l'ID perché è ritornato sulla chat!
|
||||
await User.SetTelegramIdSuccess(idapp, recold._id, recold.profile.teleg_id_old);
|
||||
|
||||
rec = await User.findOne({
|
||||
idapp,
|
||||
'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
}
|
||||
|
||||
}
|
||||
return (!!rec) ? rec : null;
|
||||
}).catch((e) => {
|
||||
console.error('UserExistByIdTelegram', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.UsersByIdTelegram = async function (idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean().then((rec) => {
|
||||
return (!!rec) ? rec : null;
|
||||
}).catch((e) => {
|
||||
console.error('UserExistByIdTelegram', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.setPicProfile = async function (idapp, username, imgpic) {
|
||||
const User = this;
|
||||
@@ -3291,7 +3298,9 @@ UserSchema.statics.SetTelegramWasBlocked = async function (idapp, teleg_id) {
|
||||
'profile.teleg_id': 0,
|
||||
};
|
||||
|
||||
if (tools.sulServer()) {
|
||||
|
||||
// if (tools.sulServer()) {
|
||||
if (true) {
|
||||
|
||||
const ris = await User.findOneAndUpdate({
|
||||
idapp,
|
||||
@@ -4889,7 +4898,7 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, v
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
|
||||
recUser.profile.reaction = await Reaction.find({idapp, username: recUser.username}).lean();
|
||||
recUser.profile.reaction = await Reaction.find({ idapp, username: recUser.username }).lean();
|
||||
|
||||
recUser.profile.manage_mygroups = listManageGroups
|
||||
? listManageGroups
|
||||
@@ -5003,9 +5012,18 @@ UserSchema.statics.moverecordsFavorite = async function (tab) {
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
console.log('fine moverecordsFavorite');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.removerecordsFavorite = async function () {
|
||||
// Rimuovi i record del vecchio schema
|
||||
const attivacanc = false;
|
||||
|
||||
const attivacanc = true;
|
||||
|
||||
if (attivacanc) {
|
||||
const queryfind = { idapp: '13' };
|
||||
await User.findOneAndUpdate(queryfind, {
|
||||
@@ -5019,12 +5037,6 @@ UserSchema.statics.moverecordsFavorite = async function (tab) {
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
console.log('fine moverecordsFavorite');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.updateVersion = async function (userversion, recUser) {
|
||||
|
||||
Reference in New Issue
Block a user