- aggiunto il Comune di Residenza alla REgistrazione e al Tutorial

This commit is contained in:
Surya Paolo
2025-11-27 00:48:58 +01:00
parent 18790ee379
commit acb685f819
12 changed files with 134 additions and 116 deletions

View File

@@ -324,7 +324,6 @@ html(lang="it")
//- CTA principale //- CTA principale
.cta-section .cta-section
.cta-title Ammetti #{usernameInvitato} alla comunità RISO
a.cta-button(href=linkAmmissione target="_blank") a.cta-button(href=linkAmmissione target="_blank")
span.button-icon ✓ span.button-icon ✓
| Sì, Confermo | Sì, Confermo

View File

@@ -857,4 +857,6 @@ Sab 08/11 ORE 20:24: 🤖: Da Surya Ar (SuryaSecondo):
Dom 09/11 ORE 18:36: 🤖: Da Sùrya undefined (surya1977): Dom 09/11 ORE 18:36: 🤖: Da Sùrya undefined (surya1977):
✅ surya4 è stato Ammesso correttamente (da surya1977)! ✅ surya4 è stato Ammesso correttamente (da surya1977)!
Mar 18/11 ORE 22:31: 🤖: Da Sùrya undefined (surya1977): Mar 18/11 ORE 22:31: 🤖: Da Sùrya undefined (surya1977):
✅ surya8 è stato Ammesso correttamente (da surya1977)! ✅ surya8 è stato Ammesso correttamente (da surya1977)!
Gio 27/11 ORE 00:43: 🤖: Da Sùrya undefined (surya1977):
✅ test123 è stato Ammesso correttamente (da surya1977)!

View File

@@ -16,7 +16,7 @@ const { ObjectId } = require('mongodb');
const tableModel = shared_consts.TABLES_ATTIVITAS; const tableModel = shared_consts.TABLES_ATTIVITAS;
// Resolving error Unknown modifier: $pushAll // Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => { mongoose.plugin((schema) => {
schema.options.usePushEach = true; schema.options.usePushEach = true;
}); });
@@ -44,9 +44,9 @@ const AttivitaSchema = new Schema(
idCity: [ idCity: [
{ {
type: Number, type: Number,
}], },
logo: ],
{ logo: {
imagefile: { imagefile: {
type: String, type: String,
}, },
@@ -68,7 +68,8 @@ const AttivitaSchema = new Schema(
description: { description: {
type: String, type: String,
}, },
}], },
],
note: { note: {
type: String, type: String,
default: '', default: '',
@@ -107,7 +108,7 @@ const AttivitaSchema = new Schema(
coordinates: { coordinates: {
type: [Number], // L'array dovrebbe contenere lon e lat type: [Number], // L'array dovrebbe contenere lon e lat
required: false, required: false,
index: '2dsphere' // Indice geospaziale [lng, lat] index: '2dsphere', // Indice geospaziale [lng, lat]
}, },
}, },
@@ -123,23 +124,21 @@ const AttivitaSchema = new Schema(
whatsapp: { whatsapp: {
type: String, type: String,
}, },
createdBy: { // Username del creatore (proponente) createdBy: {
// Username del creatore (proponente)
type: String, type: String,
}, },
//**ADDFIELD_ATTIVITA //**ADDFIELD_ATTIVITA
}, },
...Reaction.getFieldsForReactions(), ...Reaction.getFieldsForReactions(),
...tools.getFieldsForAnnunci() ...tools.getFieldsForAnnunci(),
}, { strict: false }); },
);
AttivitaSchema.pre('save', async function (next) { AttivitaSchema.pre('save', async function (next) {
if (this.isNew) { if (this.isNew) {
if (!this.date_created) if (!this.date_created) this.date_created = new Date();
this.date_created = new Date();
} }
next(); next();
@@ -148,15 +147,11 @@ AttivitaSchema.pre('save', async function (next) {
AttivitaSchema.statics.findAllIdApp = async function (idapp) { AttivitaSchema.statics.findAllIdApp = async function (idapp) {
const Attivita = this; const Attivita = this;
const query = [ const query = [{ $match: { idapp } }, { $sort: { descr: 1 } }];
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await Attivita.aggregate(query).then((arrrec) => { return await Attivita.aggregate(query).then((arrrec) => {
return arrrec; return arrrec;
}); });
}; };
AttivitaSchema.statics.getFieldsForSearch = function () { AttivitaSchema.statics.getFieldsForSearch = function () {
@@ -197,39 +192,37 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
let query = [ let query = [
{ {
'$match': { $match: {
'_id': idSkill, idapp _id: idSkill,
idapp,
}, },
}, },
{ {
'$sort': { $sort: {
'desc': 1, desc: 1,
}, },
}, },
{ {
'$addFields': { $addFields: {
'myId1': { myId1: {
'$toObjectId': '$userId', $toObjectId: '$userId',
}, },
}, },
}, },
{ {
'$lookup': { $lookup: {
'from': 'users', from: 'users',
'localField': 'myId1', localField: 'myId1',
'foreignField': '_id', foreignField: '_id',
'as': 'user', as: 'user',
}, },
}, },
{ {
'$replaceRoot': { $replaceRoot: {
'newRoot': { newRoot: {
'$mergeObjects': [ $mergeObjects: [
{ {
'$arrayElemAt': [ $arrayElemAt: ['$user', 0],
'$user',
0,
],
}, },
'$$ROOT', '$$ROOT',
], ],
@@ -240,22 +233,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
$project: shared_consts.getProjectForAll({}, tableModel), $project: shared_consts.getProjectForAll({}, tableModel),
}, },
{ {
'$lookup': { $lookup: {
'from': 'skills', from: 'skills',
'localField': 'idSkill', localField: 'idSkill',
'foreignField': '_id', foreignField: '_id',
'as': 'recSkill', as: 'recSkill',
}, },
}, },
{ {
'$replaceRoot': { $replaceRoot: {
'newRoot': { newRoot: {
'$mergeObjects': [ $mergeObjects: [
{ {
'$arrayElemAt': [ $arrayElemAt: ['$recSkill', 0],
'$recSkill',
0,
],
}, },
'$$ROOT', '$$ROOT',
], ],
@@ -266,22 +256,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
$project: shared_consts.getProjectForAll({}, tableModel), $project: shared_consts.getProjectForAll({}, tableModel),
}, },
{ {
'$lookup': { $lookup: {
'from': 'sectors', from: 'sectors',
'localField': 'idSector', localField: 'idSector',
'foreignField': '_id', foreignField: '_id',
'as': 'sector', as: 'sector',
}, },
}, },
{ {
'$replaceRoot': { $replaceRoot: {
'newRoot': { newRoot: {
'$mergeObjects': [ $mergeObjects: [
{ {
'$arrayElemAt': [ $arrayElemAt: ['$sector', 0],
'$sector',
0,
],
}, },
'$$ROOT', '$$ROOT',
], ],
@@ -292,14 +279,11 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
$project: shared_consts.getProjectForAll({}, tableModel), $project: shared_consts.getProjectForAll({}, tableModel),
}, },
{ {
'$replaceRoot': { $replaceRoot: {
'newRoot': { newRoot: {
'$mergeObjects': [ $mergeObjects: [
{ {
'$arrayElemAt': [ $arrayElemAt: ['$attivita', 0],
'$attivita',
0,
],
}, },
'$$ROOT', '$$ROOT',
], ],
@@ -310,22 +294,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) {
$project: shared_consts.getProjectForAll({}, tableModel), $project: shared_consts.getProjectForAll({}, tableModel),
}, },
{ {
'$lookup': { $lookup: {
'from': 'cities', from: 'cities',
'localField': 'idCity', localField: 'idCity',
'foreignField': '_id', foreignField: '_id',
'as': 'mycities', as: 'mycities',
}, },
}, },
{ {
'$replaceRoot': { $replaceRoot: {
'newRoot': { newRoot: {
'$mergeObjects': [ $mergeObjects: [
{ {
'$arrayElemAt': [ $arrayElemAt: ['$mycities', 0],
'$mycities',
0,
],
}, },
'$$ROOT', '$$ROOT',
], ],
@@ -374,24 +355,23 @@ AttivitaSchema.statics.getProject = function (proj_add2) {
//**ADDFIELD_ATTIVITA //**ADDFIELD_ATTIVITA
}; };
const proj_add = shared_consts.getProjectForAll(proj_add2) const proj_add = shared_consts.getProjectForAll(proj_add2);
return Object.assign({}, proj, proj_add); return Object.assign({}, proj, proj_add);
};
}
AttivitaSchema.statics.getCompleteRecord = function (idapp, id) { AttivitaSchema.statics.getCompleteRecord = function (idapp, id) {
const Attivita = this; const Attivita = this;
return Attivita.getMyRecById(idapp, id); return Attivita.getMyRecById(idapp, id);
}; };
const Attivita = mongoose.model('Attivita', AttivitaSchema); const Attivita = mongoose.model('Attivita', AttivitaSchema);
Attivita.createIndexes() Attivita.createIndexes()
.then(() => { }) .then(() => {})
.catch((err) => { throw err; }); .catch((err) => {
throw err;
});
module.exports = { Attivita }; module.exports = { Attivita };

View File

@@ -169,6 +169,8 @@ CitySchema.statics.executeQueryPickup = async function (idapp, params) {
{ {
$project: { $project: {
comune: { $concat: ["$comune", " (", "$prov", ")"] }, comune: { $concat: ["$comune", " (", "$prov", ")"] },
comune_solo: { $concat: ["$comune", ""] },
prov: 1,
}, },
}, },
]; ];
@@ -189,6 +191,8 @@ CitySchema.statics.executeQueryPickup = async function (idapp, params) {
{ {
$project: { $project: {
comune: { $concat: ["$comune", " (", "$prov", ")"] }, comune: { $concat: ["$comune", " (", "$prov", ")"] },
comune_solo: { $concat: ["$comune", ""] },
prov: 1,
}, },
}, },
]; ];

View File

@@ -103,7 +103,7 @@ const MySkillSchema = new Schema(
}, },
...Reaction.getFieldsForReactions(), ...Reaction.getFieldsForReactions(),
...tools.getFieldsForAnnunci() ...tools.getFieldsForAnnunci()
}, { strict: false }); }, { strict: true });
MySkillSchema.index({ 'idapp': 1 }); MySkillSchema.index({ 'idapp': 1 });
@@ -340,6 +340,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
}; };
query = [...query, { ...toadd }]; query = [...query, { ...toadd }];
return MySkill.aggregate(query).then((rec) => { return MySkill.aggregate(query).then((rec) => {
return rec ? rec[0] : null; return rec ? rec[0] : null;

View File

@@ -1339,6 +1339,7 @@ sendNotifSchema.statics.getNotificationRecipients = async function (myrecnotifpa
username: 1, username: 1,
'profile.notifs': 1, 'profile.notifs': 1,
'profile.mycircuits': 1, 'profile.mycircuits': 1,
'profile.resid_str_comune': 1,
'profile.resid_province': 1, 'profile.resid_province': 1,
'profile.resid_card': 1, 'profile.resid_card': 1,
'profile.notif_idCities': 1, 'profile.notif_idCities': 1,

View File

@@ -5752,6 +5752,7 @@ UserSchema.statics.getQueryLastUsersStretteDiMano = async function (idapp) {
$first: { $first: {
profile: { profile: {
img: '$userfriend.profile.img', img: '$userfriend.profile.img',
resid_str_comune: '$userfriend.profile.resid_str_comune',
resid_province: '$userfriend.profile.resid_province', resid_province: '$userfriend.profile.resid_province',
note: '$userfriend.profile.note', note: '$userfriend.profile.note',
}, },
@@ -5765,6 +5766,7 @@ UserSchema.statics.getQueryLastUsersStretteDiMano = async function (idapp) {
$first: { $first: {
img: '$profile.img', img: '$profile.img',
handshake: '$profile.handshake', handshake: '$profile.handshake',
resid_str_comune: '$profile.resid_str_comune',
resid_province: '$profile.resid_province', resid_province: '$profile.resid_province',
note: '$profile.note', note: '$profile.note',
}, },

View File

@@ -37,6 +37,21 @@ const Macro = require('../modules/Macro');
class CronMod { class CronMod {
constructor() {} constructor() {}
async RimuoviInteri(mytable) {
try {
console.log('INIZIO - RimuoviInteri ', mytable.modelName);
const arr = await mytable.find({ _id: { $lte: 10000 } });
console.log(' search interi...', arr.length);
const ris = await mytable.deleteMany({ _id: { $lte: 10000 } });
console.log('FINE - RimuoviInteri ', mytable.modelName, ris);
} catch (err) {
console.error(err);
}
}
async eseguiDbOp(idapp, mydata, req, res) { async eseguiDbOp(idapp, mydata, req, res) {
let ris = await User.DbOp(idapp, mydata); let ris = await User.DbOp(idapp, mydata);
@@ -67,11 +82,11 @@ class CronMod {
} else if (mydata.dbop === 'EsportaInfoProductExtra') { } else if (mydata.dbop === 'EsportaInfoProductExtra') {
const macro = new Macro(idapp, {}); const macro = new Macro(idapp, {});
mystr = await macro.EsportaInfoProductExtra(); mystr = await macro.EsportaInfoProductExtra();
ris = { mystr }; ris = { mystr };
} else if (mydata.dbop === 'ImportaInfoProductExtra') { } else if (mydata.dbop === 'ImportaInfoProductExtra') {
const macro = new Macro(idapp, {}); const macro = new Macro(idapp, {});
mystr = await macro.ImportaInfoProductExtra(); mystr = await macro.ImportaInfoProductExtra();
ris = { mystr }; ris = { mystr };
} else if (mydata.dbop === 'ScraperEstraiDatiAmazon-NoUpdate') { } else if (mydata.dbop === 'ScraperEstraiDatiAmazon-NoUpdate') {
mystr = await AmazonBookScraper.ScraperMultipleDataAmazon(idapp, { mystr = await AmazonBookScraper.ScraperMultipleDataAmazon(idapp, {
update: false, update: false,
@@ -425,6 +440,20 @@ class CronMod {
await ConvertiDaIntAStr(MyGroup); await ConvertiDaIntAStr(MyGroup);
console.log('FINE - Conversioni'); console.log('FINE - Conversioni');
} else if (mydata.dbop === 'RemoveDatiInutiliMySkill') {
const { MySkill } = require('../models/myskill');
try {
const docs = await MySkill.find({}).lean();
for (const doc of docs) {
await MySkill.replaceOne({ _id: doc._id }, doc);
}
ris = true;
console.log('RIS', ris);
} catch (e) {
console.error('err', e);
}
} else if (mydata.dbop === 'Removeinteger') { } else if (mydata.dbop === 'Removeinteger') {
const { MySkill } = require('../models/myskill'); const { MySkill } = require('../models/myskill');
const { MyBacheca } = require('../models/mybacheca'); const { MyBacheca } = require('../models/mybacheca');
@@ -434,11 +463,11 @@ class CronMod {
console.log('INIZIO - Rimozione'); console.log('INIZIO - Rimozione');
await RimuoviInteri(MySkill); await this.RimuoviInteri(MySkill);
await RimuoviInteri(MyBacheca); await this.RimuoviInteri(MyBacheca);
await RimuoviInteri(MyHosp); await this.RimuoviInteri(MyHosp);
await RimuoviInteri(MyGood); await this.RimuoviInteri(MyGood);
await RimuoviInteri(MyGroup); await this.RimuoviInteri(MyGroup);
console.log('FINE - Rimozione'); console.log('FINE - Rimozione');
} else if (mydata.dbop === 'createAllCircuits') { } else if (mydata.dbop === 'createAllCircuits') {

View File

@@ -1092,20 +1092,6 @@ async function ConvertiDaIntAStr(mytable) {
console.error(err); console.error(err);
} }
} }
async function RimuoviInteri(mytable) {
try {
console.log('INIZIO - RimuoviInteri ', mytable.modelName);
const arr = await mytable.find({ _id: { $lte: 10000 } });
console.log(' search interi...', arr.length);
const ris = await mytable.deleteMany({ _id: { $lte: 10000 } });
console.log('FINE - RimuoviInteri ', mytable.modelName, ris);
} catch (err) {
console.error(err);
}
}
async function eseguiDbOpUser(idapp, mydata, locale, req, res) { async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
let ris = await User.DbOp(idapp, mydata); let ris = await User.DbOp(idapp, mydata);
@@ -1225,6 +1211,7 @@ router.post('/infomap', authenticate, async (req, res) => {
aportador_solidario: 1, aportador_solidario: 1,
lasttimeonline: 1, lasttimeonline: 1,
'profile.img': 1, 'profile.img': 1,
'profile.resid_str_comune': 1,
'profile.resid_province': 1, 'profile.resid_province': 1,
lat: '$provinceInfo.lat', // Aggiunge il campo lat preso dalla provincia lat: '$provinceInfo.lat', // Aggiunge il campo lat preso dalla provincia
long: '$provinceInfo.long', // Aggiunge il campo long preso dalla provincia long: '$provinceInfo.long', // Aggiunge il campo long preso dalla provincia

View File

@@ -36,8 +36,6 @@ const { MsgTemplate } = require('../models/msg_template');
const i18n = require('i18n'); const i18n = require('i18n');
let url = process.env.URL || 'https://<PUBLIC-URL>'; let url = process.env.URL || 'https://<PUBLIC-URL>';
const Benvenuto = '💓💓💓 Benvenuto/a!'; const Benvenuto = '💓💓💓 Benvenuto/a!';
@@ -918,7 +916,6 @@ const MyTelegramBot = {
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest, callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest,
}, },
]); ]);
} }
/*{ /*{
text: '🚫 Rifiuta ' + myuser.username, text: '🚫 Rifiuta ' + myuser.username,
@@ -4569,8 +4566,20 @@ if (true) {
`${userDest.username}` `${userDest.username}`
); );
let token = ''; //++SISTEMAERE QUI!
const dati = {
token,
};
// Invia una email alla persona che è stata ammessa // Invia una email alla persona che è stata ammessa
const ris = await sendemail.sendEmail_Utente_Ammesso(user.lang, userDest, null, user.idapp, null); const ris = await sendemail.sendEmail_Utente_Ammesso(
user.lang,
userDest,
null,
user.idapp,
dati,
);
await local_sendMsgTelegram(user.idapp, data.username, msgOrig); await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest); await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);

View File

@@ -2734,6 +2734,8 @@ module.exports = {
filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } }); filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } });
if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE)) if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE))
filtriadded.push({ 'profile.resid_province': { $exists: true } }); filtriadded.push({ 'profile.resid_province': { $exists: true } });
if (params.filterand.includes(shared_consts.FILTER_USER_COMUNE))
filtriadded.push({ 'profile.resid_str_comune': { $exists: true } });
if (params.filterand.includes(shared_consts.FILTER_USER_SENZA_PROVINCE)) if (params.filterand.includes(shared_consts.FILTER_USER_SENZA_PROVINCE))
filtriadded.push({ 'profile.resid_province': { $exists: false } }); filtriadded.push({ 'profile.resid_province': { $exists: false } });
if (params.filterand.includes(shared_consts.FILTER_ATTIVI)) if (params.filterand.includes(shared_consts.FILTER_ATTIVI))

View File

@@ -56,6 +56,7 @@ module.exports = {
FILTER_SENZA_NOTE: 1073741824, FILTER_SENZA_NOTE: 1073741824,
FILTER_DA_CONTATTARE: 2147483648, FILTER_DA_CONTATTARE: 2147483648,
FILTER_FACILITATORE: 4294967296, FILTER_FACILITATORE: 4294967296,
FILTER_USER_COMUNE: 8589934592,
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1, OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2, OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
@@ -1028,6 +1029,7 @@ module.exports = {
'profile.qualifica': 1, 'profile.qualifica': 1,
'profile.note': 1, 'profile.note': 1,
'profile.da_contattare': 1, 'profile.da_contattare': 1,
'profile.resid_str_comune': 1,
'profile.resid_province': 1, 'profile.resid_province': 1,
'profile.resid_card': 1, 'profile.resid_card': 1,
'profile.username_telegram': 1, 'profile.username_telegram': 1,