diff --git a/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug b/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug index 15116fe..56b096a 100755 --- a/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug +++ b/emails/RISO/reg_chiedi_ammettere_all_invitante/it/html.pug @@ -324,7 +324,6 @@ html(lang="it") //- CTA principale .cta-section - .cta-title Ammetti #{usernameInvitato} alla comunità RISO a.cta-button(href=linkAmmissione target="_blank") span.button-icon ✓ | Sì, Confermo diff --git a/logevents.txt b/logevents.txt index 0de9b17..905829c 100644 --- a/logevents.txt +++ b/logevents.txt @@ -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): ✅ surya4 è stato Ammesso correttamente (da surya1977)! Mar 18/11 ORE 22:31: 🤖: Da Sùrya undefined (surya1977): -✅ surya8 è stato Ammesso correttamente (da surya1977)! \ No newline at end of file +✅ surya8 è stato Ammesso correttamente (da surya1977)! +Gio 27/11 ORE 00:43: 🤖: Da Sùrya undefined (surya1977): +✅ test123 è stato Ammesso correttamente (da surya1977)! \ No newline at end of file diff --git a/src/models/attivita.js b/src/models/attivita.js index fed2693..d46016d 100755 --- a/src/models/attivita.js +++ b/src/models/attivita.js @@ -16,7 +16,7 @@ const { ObjectId } = require('mongodb'); const tableModel = shared_consts.TABLES_ATTIVITAS; // Resolving error Unknown modifier: $pushAll -mongoose.plugin(schema => { +mongoose.plugin((schema) => { schema.options.usePushEach = true; }); @@ -44,9 +44,9 @@ const AttivitaSchema = new Schema( idCity: [ { type: Number, - }], - logo: - { + }, + ], + logo: { imagefile: { type: String, }, @@ -68,7 +68,8 @@ const AttivitaSchema = new Schema( description: { type: String, }, - }], + }, + ], note: { type: String, default: '', @@ -107,7 +108,7 @@ const AttivitaSchema = new Schema( coordinates: { type: [Number], // L'array dovrebbe contenere lon e lat required: false, - index: '2dsphere' // Indice geospaziale [lng, lat] + index: '2dsphere', // Indice geospaziale [lng, lat] }, }, @@ -123,23 +124,21 @@ const AttivitaSchema = new Schema( whatsapp: { type: String, }, - createdBy: { // Username del creatore (proponente) + createdBy: { + // Username del creatore (proponente) type: String, }, - //**ADDFIELD_ATTIVITA }, ...Reaction.getFieldsForReactions(), - ...tools.getFieldsForAnnunci() - }, { strict: false }); - - + ...tools.getFieldsForAnnunci(), + }, +); AttivitaSchema.pre('save', async function (next) { if (this.isNew) { - if (!this.date_created) - this.date_created = new Date(); + if (!this.date_created) this.date_created = new Date(); } next(); @@ -148,15 +147,11 @@ AttivitaSchema.pre('save', async function (next) { AttivitaSchema.statics.findAllIdApp = async function (idapp) { const Attivita = this; - const query = [ - { $match: { idapp } }, - { $sort: { descr: 1 } }, - ]; + const query = [{ $match: { idapp } }, { $sort: { descr: 1 } }]; return await Attivita.aggregate(query).then((arrrec) => { return arrrec; }); - }; AttivitaSchema.statics.getFieldsForSearch = function () { @@ -197,39 +192,37 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) { let query = [ { - '$match': { - '_id': idSkill, idapp + $match: { + _id: idSkill, + idapp, }, }, { - '$sort': { - 'desc': 1, + $sort: { + desc: 1, }, }, { - '$addFields': { - 'myId1': { - '$toObjectId': '$userId', + $addFields: { + myId1: { + $toObjectId: '$userId', }, }, }, { - '$lookup': { - 'from': 'users', - 'localField': 'myId1', - 'foreignField': '_id', - 'as': 'user', + $lookup: { + from: 'users', + localField: 'myId1', + foreignField: '_id', + as: 'user', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$user', - 0, - ], + $arrayElemAt: ['$user', 0], }, '$$ROOT', ], @@ -240,22 +233,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'skills', - 'localField': 'idSkill', - 'foreignField': '_id', - 'as': 'recSkill', + $lookup: { + from: 'skills', + localField: 'idSkill', + foreignField: '_id', + as: 'recSkill', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$recSkill', - 0, - ], + $arrayElemAt: ['$recSkill', 0], }, '$$ROOT', ], @@ -266,22 +256,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'sectors', - 'localField': 'idSector', - 'foreignField': '_id', - 'as': 'sector', + $lookup: { + from: 'sectors', + localField: 'idSector', + foreignField: '_id', + as: 'sector', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$sector', - 0, - ], + $arrayElemAt: ['$sector', 0], }, '$$ROOT', ], @@ -292,14 +279,11 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$attivita', - 0, - ], + $arrayElemAt: ['$attivita', 0], }, '$$ROOT', ], @@ -310,22 +294,19 @@ AttivitaSchema.statics.getMyRecById = function (idapp, idSkill) { $project: shared_consts.getProjectForAll({}, tableModel), }, { - '$lookup': { - 'from': 'cities', - 'localField': 'idCity', - 'foreignField': '_id', - 'as': 'mycities', + $lookup: { + from: 'cities', + localField: 'idCity', + foreignField: '_id', + as: 'mycities', }, }, { - '$replaceRoot': { - 'newRoot': { - '$mergeObjects': [ + $replaceRoot: { + newRoot: { + $mergeObjects: [ { - '$arrayElemAt': [ - '$mycities', - 0, - ], + $arrayElemAt: ['$mycities', 0], }, '$$ROOT', ], @@ -374,24 +355,23 @@ AttivitaSchema.statics.getProject = function (proj_add2) { //**ADDFIELD_ATTIVITA }; - const proj_add = shared_consts.getProjectForAll(proj_add2) + const proj_add = shared_consts.getProjectForAll(proj_add2); return Object.assign({}, proj, proj_add); - -} +}; AttivitaSchema.statics.getCompleteRecord = function (idapp, id) { const Attivita = this; return Attivita.getMyRecById(idapp, id); - }; const Attivita = mongoose.model('Attivita', AttivitaSchema); Attivita.createIndexes() - .then(() => { }) - .catch((err) => { throw err; }); - + .then(() => {}) + .catch((err) => { + throw err; + }); module.exports = { Attivita }; diff --git a/src/models/city.js b/src/models/city.js index 14c2d6e..97ec87b 100755 --- a/src/models/city.js +++ b/src/models/city.js @@ -169,6 +169,8 @@ CitySchema.statics.executeQueryPickup = async function (idapp, params) { { $project: { comune: { $concat: ["$comune", " (", "$prov", ")"] }, + comune_solo: { $concat: ["$comune", ""] }, + prov: 1, }, }, ]; @@ -189,6 +191,8 @@ CitySchema.statics.executeQueryPickup = async function (idapp, params) { { $project: { comune: { $concat: ["$comune", " (", "$prov", ")"] }, + comune_solo: { $concat: ["$comune", ""] }, + prov: 1, }, }, ]; diff --git a/src/models/myskill.js b/src/models/myskill.js index dd14bde..62935b7 100755 --- a/src/models/myskill.js +++ b/src/models/myskill.js @@ -103,7 +103,7 @@ const MySkillSchema = new Schema( }, ...Reaction.getFieldsForReactions(), ...tools.getFieldsForAnnunci() - }, { strict: false }); + }, { strict: true }); MySkillSchema.index({ 'idapp': 1 }); @@ -340,6 +340,7 @@ MySkillSchema.statics.getMyRecById = function (idapp, idSkill) { }; query = [...query, { ...toadd }]; + return MySkill.aggregate(query).then((rec) => { return rec ? rec[0] : null; diff --git a/src/models/sendnotif.js b/src/models/sendnotif.js index fabf288..8dc274d 100755 --- a/src/models/sendnotif.js +++ b/src/models/sendnotif.js @@ -1339,6 +1339,7 @@ sendNotifSchema.statics.getNotificationRecipients = async function (myrecnotifpa username: 1, 'profile.notifs': 1, 'profile.mycircuits': 1, + 'profile.resid_str_comune': 1, 'profile.resid_province': 1, 'profile.resid_card': 1, 'profile.notif_idCities': 1, diff --git a/src/models/user.js b/src/models/user.js index ffdf04d..681acdf 100755 --- a/src/models/user.js +++ b/src/models/user.js @@ -5752,6 +5752,7 @@ UserSchema.statics.getQueryLastUsersStretteDiMano = async function (idapp) { $first: { profile: { img: '$userfriend.profile.img', + resid_str_comune: '$userfriend.profile.resid_str_comune', resid_province: '$userfriend.profile.resid_province', note: '$userfriend.profile.note', }, @@ -5765,6 +5766,7 @@ UserSchema.statics.getQueryLastUsersStretteDiMano = async function (idapp) { $first: { img: '$profile.img', handshake: '$profile.handshake', + resid_str_comune: '$profile.resid_str_comune', resid_province: '$profile.resid_province', note: '$profile.note', }, diff --git a/src/modules/CronMod.js b/src/modules/CronMod.js index cca5f6a..04f6c66 100644 --- a/src/modules/CronMod.js +++ b/src/modules/CronMod.js @@ -37,6 +37,21 @@ const Macro = require('../modules/Macro'); class CronMod { 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) { let ris = await User.DbOp(idapp, mydata); @@ -67,11 +82,11 @@ class CronMod { } else if (mydata.dbop === 'EsportaInfoProductExtra') { const macro = new Macro(idapp, {}); mystr = await macro.EsportaInfoProductExtra(); - ris = { mystr }; + ris = { mystr }; } else if (mydata.dbop === 'ImportaInfoProductExtra') { const macro = new Macro(idapp, {}); mystr = await macro.ImportaInfoProductExtra(); - ris = { mystr }; + ris = { mystr }; } else if (mydata.dbop === 'ScraperEstraiDatiAmazon-NoUpdate') { mystr = await AmazonBookScraper.ScraperMultipleDataAmazon(idapp, { update: false, @@ -425,6 +440,20 @@ class CronMod { await ConvertiDaIntAStr(MyGroup); 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') { const { MySkill } = require('../models/myskill'); const { MyBacheca } = require('../models/mybacheca'); @@ -434,11 +463,11 @@ class CronMod { console.log('INIZIO - Rimozione'); - await RimuoviInteri(MySkill); - await RimuoviInteri(MyBacheca); - await RimuoviInteri(MyHosp); - await RimuoviInteri(MyGood); - await RimuoviInteri(MyGroup); + await this.RimuoviInteri(MySkill); + await this.RimuoviInteri(MyBacheca); + await this.RimuoviInteri(MyHosp); + await this.RimuoviInteri(MyGood); + await this.RimuoviInteri(MyGroup); console.log('FINE - Rimozione'); } else if (mydata.dbop === 'createAllCircuits') { diff --git a/src/router/users_router.js b/src/router/users_router.js index dfbfd4e..1b4d334 100755 --- a/src/router/users_router.js +++ b/src/router/users_router.js @@ -1092,20 +1092,6 @@ async function ConvertiDaIntAStr(mytable) { 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) { let ris = await User.DbOp(idapp, mydata); @@ -1225,6 +1211,7 @@ router.post('/infomap', authenticate, async (req, res) => { aportador_solidario: 1, lasttimeonline: 1, 'profile.img': 1, + 'profile.resid_str_comune': 1, 'profile.resid_province': 1, lat: '$provinceInfo.lat', // Aggiunge il campo lat preso dalla provincia long: '$provinceInfo.long', // Aggiunge il campo long preso dalla provincia diff --git a/src/telegram/telegrambot.js b/src/telegram/telegrambot.js index 8192a74..cf3cd5e 100644 --- a/src/telegram/telegrambot.js +++ b/src/telegram/telegrambot.js @@ -36,8 +36,6 @@ const { MsgTemplate } = require('../models/msg_template'); const i18n = require('i18n'); - - let url = process.env.URL || 'https://'; const Benvenuto = '💓💓💓 Benvenuto/a!'; @@ -918,7 +916,6 @@ const MyTelegramBot = { callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest, }, ]); - } /*{ text: '🚫 Rifiuta ' + myuser.username, @@ -4569,8 +4566,20 @@ if (true) { `${userDest.username}` ); + let token = ''; //++SISTEMAERE QUI! + + const dati = { + token, + }; + // 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.userDest, msgDest); diff --git a/src/tools/general.js b/src/tools/general.js index 0513267..95d0635 100755 --- a/src/tools/general.js +++ b/src/tools/general.js @@ -2734,6 +2734,8 @@ module.exports = { filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } }); if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE)) 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)) filtriadded.push({ 'profile.resid_province': { $exists: false } }); if (params.filterand.includes(shared_consts.FILTER_ATTIVI)) diff --git a/src/tools/shared_nodejs.js b/src/tools/shared_nodejs.js index 4fe9e0d..251545d 100755 --- a/src/tools/shared_nodejs.js +++ b/src/tools/shared_nodejs.js @@ -56,6 +56,7 @@ module.exports = { FILTER_SENZA_NOTE: 1073741824, FILTER_DA_CONTATTARE: 2147483648, FILTER_FACILITATORE: 4294967296, + FILTER_USER_COMUNE: 8589934592, OPTIONS_SEARCH_ONLY_FULL_WORDS: 1, OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2, @@ -1028,6 +1029,7 @@ module.exports = { 'profile.qualifica': 1, 'profile.note': 1, 'profile.da_contattare': 1, + 'profile.resid_str_comune': 1, 'profile.resid_province': 1, 'profile.resid_card': 1, 'profile.username_telegram': 1,