Cataloghi...
This commit is contained in:
@@ -42,13 +42,13 @@ const CatalogSchema = new Schema({
|
||||
type: String,
|
||||
},
|
||||
foto_collana: Foto,
|
||||
idCollana: {
|
||||
type: String,
|
||||
},
|
||||
idCollane: [{
|
||||
type: Number,
|
||||
}],
|
||||
descr_introduttiva: {
|
||||
type: String,
|
||||
},
|
||||
idTemplateScheda: {
|
||||
idPageAssigned: {
|
||||
type: String,
|
||||
},
|
||||
referenti: [{
|
||||
@@ -92,9 +92,24 @@ CatalogSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const Catalog = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
const arrrec = await Catalog.aggregate([
|
||||
// Filtra i documenti per idapp
|
||||
{ $match: { idapp } },
|
||||
|
||||
const arrrec = await Catalog.find(myfind).lean().sort({ title: 1 });
|
||||
// Ordina i risultati per titolo
|
||||
{ $sort: { title: 1 } },
|
||||
|
||||
// Esegui il join con la collezione Collana
|
||||
{
|
||||
$lookup: {
|
||||
from: "collanas", // Nome della collezione Collana
|
||||
localField: "idCollane", // Campo in Catalog
|
||||
foreignField: "idCollana", // Campo in Collana
|
||||
as: "collana_info" // Nome del campo che conterrà i risultati del join
|
||||
}
|
||||
},
|
||||
|
||||
]);
|
||||
|
||||
return arrrec;
|
||||
};
|
||||
|
||||
@@ -18,10 +18,7 @@ const CollanaSchema = new Schema({
|
||||
idCollana: {
|
||||
type: Number,
|
||||
},
|
||||
descrizione: {
|
||||
type: String,
|
||||
},
|
||||
descrizione_estesa: {
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
dataOra: {
|
||||
|
||||
@@ -60,7 +60,7 @@ const catalogo = new Schema(
|
||||
excludeproductTypes: [{ type: Number }],
|
||||
editore: [{ type: String }],
|
||||
argomenti: [{ type: String }],
|
||||
idCollana: { type: Number },
|
||||
idCollane: [{ type: Number }],
|
||||
sort_field: { type: String },
|
||||
sort_dir: { type: Number },
|
||||
pdf: { type: Boolean },
|
||||
@@ -361,7 +361,21 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
const arrrec = await MyElem.find(myfind).lean().sort({ order: 1 });
|
||||
const aggiorna = false;
|
||||
|
||||
let arrrec = null;
|
||||
|
||||
if (aggiorna) {
|
||||
arrrec = await MyElem.find(myfind).sort({ order: 1 });
|
||||
for (const elem of arrrec) {
|
||||
if (elem.heightimg === 'NaNpx') {
|
||||
elem.heightimg = '';
|
||||
await elem.save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
arrrec = await MyElem.find(myfind).lean().sort({ order: 1 });
|
||||
}
|
||||
|
||||
return arrrec;
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ const scheletroScheda = {
|
||||
excludeproductTypes: [{ type: Number }],
|
||||
editore: [{ type: String }],
|
||||
argomenti: [{ type: String }],
|
||||
idCollana: { type: Number },
|
||||
idCollane: [{ type: Number }],
|
||||
author: { type: String },
|
||||
sort_field: { type: String },
|
||||
sort_dir: { type: Number },
|
||||
|
||||
@@ -870,6 +870,9 @@ UserSchema.statics.findByCredentials = function (idapp, username, password, pwdc
|
||||
UserSchema.statics.findByUsername = async function (idapp, username, alsoemail, onlyifVerifiedByAportador) {
|
||||
const User = this;
|
||||
|
||||
if (!username)
|
||||
return null;
|
||||
|
||||
const myreg = ['^', username, '$'].join('');
|
||||
let regexusername = new RegExp(myreg, 'i');
|
||||
|
||||
|
||||
@@ -134,56 +134,56 @@ module.exports = {
|
||||
{
|
||||
"_id": ObjectId("515a353c002c8298f4495bf7"),
|
||||
"idapp": "13",
|
||||
"label" : "Dono",
|
||||
"label": "🎁 Dono",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc466567de9a1f54b254f4"),
|
||||
"idapp": "13",
|
||||
"label" : "Offerta Libera",
|
||||
"label": "💸 Offerta Libera",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc454867de9a1f54b254f2"),
|
||||
"idapp": "13",
|
||||
"label" : "Baratto",
|
||||
"label": "🤝 Baratto",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f54b25412"),
|
||||
"idapp": "13",
|
||||
"label" : "Scambio Lavoro",
|
||||
"label": "💪 Scambio Lavoro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ab"),
|
||||
"idapp": "13",
|
||||
"label" : "Monete Alternative",
|
||||
"label": "🪙 Monete Alternative",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ac"),
|
||||
"idapp": "13",
|
||||
"label" : "RIS",
|
||||
"label": "🍚 RIS",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254fb"),
|
||||
"idapp": "13",
|
||||
"label" : "Euro",
|
||||
"label": "💶 Euro",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b254ff"),
|
||||
"idapp": "13",
|
||||
"label" : "Bitcoin",
|
||||
"label": "₿ Bitcoin",
|
||||
"__v": 0
|
||||
},
|
||||
{
|
||||
"_id": ObjectId("51bc482667de9a1f64b255ff"),
|
||||
"idapp": "13",
|
||||
"label" : "Banca del Tempo",
|
||||
"label": "⏳ Banca del Tempo",
|
||||
"__v": 0
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -776,7 +776,6 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
let imported = 0;
|
||||
let errors = 0;
|
||||
|
||||
|
||||
const ripopola = true;
|
||||
|
||||
if (ripopola) {
|
||||
@@ -901,7 +900,8 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
// Aggiorna la collana solo se non è stata già impostata nel record attuale
|
||||
if (recproductInfoAttuale && !recproductInfoAttuale.idCollana && product.DescrizioneCollana) {
|
||||
//if (recproductInfoAttuale && !recproductInfoAttuale.idCollana && product.DescrizioneCollana) {
|
||||
if (recproductInfoAttuale && product.DescrizioneCollana) {
|
||||
const idCollanaNum = parseInt(product.IdCollana)
|
||||
productInfo.idCollana = idCollanaNum;
|
||||
|
||||
@@ -909,7 +909,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
if (!reccollana) {
|
||||
try {
|
||||
// Non esiste questa collana, quindi la creo !
|
||||
reccoll = new Collana({ idapp, idCollana: idCollanaNum, descrizione: product.DescrizioneCollana });
|
||||
reccoll = new Collana({ idapp, idCollana: idCollanaNum, title: product.DescrizioneCollana });
|
||||
ris = await reccoll.save();
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
|
||||
@@ -220,6 +220,8 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, async (req, res) => {
|
||||
// Invio la Nuova Password richiesta dal reset!
|
||||
// Ritorna il token per poter effettuare le chiamate...
|
||||
router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
|
||||
try {
|
||||
const body = _.pick(req.body, ['idapp', 'email', 'tokenforgot', 'tokenforgot_code', 'password']);
|
||||
const idapp = body.idapp;
|
||||
const email = body.email.toLowerCase().trim();
|
||||
@@ -227,6 +229,7 @@ router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
const tokenforgot_code = body.tokenforgot_code;
|
||||
const password = body.password;
|
||||
const msg = 'Richiesta Nuova Password: idapp= ' + idapp + ' email = ' + email;
|
||||
|
||||
console.log(msg);
|
||||
|
||||
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
|
||||
@@ -272,6 +275,10 @@ router.post(process.env.LINK_UPDATE_PWD, async (req, res) => {
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error: ', e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.post('/testServer', authenticate_noerror, async (req, res) => {
|
||||
|
||||
@@ -87,6 +87,7 @@ router.post('/test1', async (req, res) => {
|
||||
|
||||
// POST /users
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
tools.mylog('POST /users');
|
||||
const body = _.pick(req.body, [
|
||||
'email',
|
||||
@@ -389,6 +390,10 @@ router.post('/', async (req, res) => {
|
||||
console.error(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
router.get('/:idapp/:username', async (req, res) => {
|
||||
|
||||
@@ -1043,11 +1043,11 @@ function startServer(app, port) {
|
||||
ws.send(JSON.stringify({ type: 'output', data: data }));
|
||||
|
||||
// Controlla se c'è una richiesta di input
|
||||
if (buffer.endsWith(': ') || buffer.includes('? ') ||
|
||||
if (buffer && (buffer.endsWith(': ') || buffer.includes('? ') ||
|
||||
buffer.toLowerCase().includes('password')
|
||||
|| buffer.includes('Inserisci')
|
||||
|| buffer.includes('Inserted')
|
||||
|| buffer.includes('(Y')
|
||||
|| buffer.includes('(Y'))
|
||||
) {
|
||||
ws.send(JSON.stringify({ type: 'input_required', prompt: data.trim() }));
|
||||
buffer = '';
|
||||
|
||||
@@ -927,7 +927,7 @@ const MyTelegramBot = {
|
||||
|
||||
let useraportador = await User.getUserShortDataByUsername(idapp, userDest);
|
||||
|
||||
if (useraportador && useraportador.tokenreg && (regexpire.toLowerCase() === useraportador.tokenreg.toLowerCase())) {
|
||||
if (useraportador && useraportador.tokenreg && useraportador.tokenreg && (regexpire && (regexpire?.toLowerCase() === useraportador.tokenreg?.toLowerCase()))) {
|
||||
const nonchiedereverifica = await User.getifRegTokenIsValid(idapp, useraportador.tokenreg);
|
||||
if (nonchiedereverifica)
|
||||
notask_verif = true;
|
||||
@@ -2103,7 +2103,7 @@ class Telegram {
|
||||
// await this.menumsg_to_Nave(msg, cmd2);
|
||||
// } else if (testo === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
|
||||
// await this.menumsg_Si_Invitati_No_7Req(msg);
|
||||
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||
} else if (cmd1 && cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||
await this.menumsg_A_Utente(msg);
|
||||
} else if (testo === Menu.SETPICPROFILE) {
|
||||
await this.setPhotoProfile(rec.user, msg.from.id);
|
||||
@@ -2838,7 +2838,7 @@ class Telegram {
|
||||
|
||||
async setUsernameInvitante(msg) {
|
||||
try {
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let mymsg = msg.text?.toString().trim().toLowerCase();
|
||||
|
||||
let nomeapp = tools.getNomeAppByIdApp(this.idapp);
|
||||
|
||||
@@ -3271,7 +3271,7 @@ class Telegram {
|
||||
getInvitanteByMsg(msg) {
|
||||
try {
|
||||
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let mymsg = msg.text?.toString().trim().toLowerCase();
|
||||
let invitante = '';
|
||||
let regexpire = '';
|
||||
const sep = '-'
|
||||
@@ -3324,8 +3324,7 @@ class Telegram {
|
||||
}
|
||||
|
||||
const rec = this.getRecInMem(msg);
|
||||
let testo = msg.text.toLowerCase().trim();
|
||||
|
||||
let testo = msg.text?.toLowerCase().trim();
|
||||
|
||||
status = this.getstatus(rec);
|
||||
if (testo === Menu.EXIT_TELEGRAM) {
|
||||
@@ -3389,7 +3388,7 @@ class Telegram {
|
||||
rec.chatId = msg.chat.id;
|
||||
rec.messageId = msg.message_id;
|
||||
rec.msgall_status = StatusMSGALL.CONFIRM;
|
||||
const cmd = rec.msgtosent.toLowerCase();
|
||||
const cmd = rec?.msgtosent?.toString().toLowerCase() ?? '';
|
||||
let achi = this.getDestinStr(msg, rec.msgall_achi, rec);
|
||||
let domanda = '';
|
||||
if (rec.msgall_domanda) {
|
||||
@@ -3716,7 +3715,7 @@ class Telegram {
|
||||
for (const rec of recuser.menuDb) {
|
||||
if (rec.active_mem) {
|
||||
if (rec.idapp === idapp && rec.lang === lang &&
|
||||
rec.label.toLowerCase() === testo) {
|
||||
rec.label?.toLowerCase() === testo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3800,7 +3799,7 @@ class Telegram {
|
||||
for (const recdb of recuser.menuDb) {
|
||||
if (recdb.active_mem) {
|
||||
if (recdb.idapp === idapp && recdb.lang === lang &&
|
||||
recdb.label.toLowerCase() === testo) {
|
||||
recdb.label?.toLowerCase() === testo) {
|
||||
if (recdb.type === shared_consts.BOTTYPE_BOTTONI_INLINE) {
|
||||
const jsonString = '[{"text": "primo", "callback_data": "1"}, {"text": "sec", "callback_data": "2"}]';
|
||||
const jsonObject = JSON.parse(jsonString);
|
||||
|
||||
@@ -5396,7 +5396,7 @@ module.exports = {
|
||||
contatto = '';
|
||||
}
|
||||
}
|
||||
if ((myrec.contact_telegram && myrec.contact_telegram.toLowerCase() !== contatto_telegram.toLowerCase()) || !contatto) {
|
||||
if ((myrec.contact_telegram && myrec.contact_telegram?.toLowerCase() !== contatto_telegram?.toLowerCase()) || !contatto) {
|
||||
contatto += '\n' + myrec.contact_telegram;
|
||||
}
|
||||
/*if (myrec.contact_phone) {
|
||||
@@ -5709,7 +5709,7 @@ module.exports = {
|
||||
const allElements = document.body.querySelectorAll('*');
|
||||
|
||||
allElements.forEach(element => {
|
||||
const tagName = element.tagName.toLowerCase();
|
||||
const tagName = element.tagName?.toLowerCase();
|
||||
|
||||
if (!allowedTags.includes(tagName)) {
|
||||
// Crea un nodo di testo e sostituisci l'elemento con quel nodo di testo
|
||||
|
||||
@@ -274,7 +274,7 @@ module.exports = {
|
||||
{ table: 'catgrps', key: 'descr' },
|
||||
{
|
||||
table: 'contribtypes',
|
||||
key: 'descr',
|
||||
keyOLD: 'descr',
|
||||
},
|
||||
{ table: 'goods', key: 'descr', key2: 'idSectorGood' },
|
||||
{ table: 'levels', key: 'descr' },
|
||||
|
||||
Reference in New Issue
Block a user