diff --git a/src/server/models/site.js b/src/server/models/site.js index 2f4d839..887ebce 100755 --- a/src/server/models/site.js +++ b/src/server/models/site.js @@ -132,6 +132,8 @@ const SiteSchema = new Schema({ type: Number, default: 0, }, + videoPromo: { type: String }, + PDFPromo: { type: String }, }, confsite: { options: { // ConfSite diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index c2be703..c89a2c6 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -668,12 +668,49 @@ router.post('/getpage', async (req, res) => { const idapp = req.body.idapp; const mypath = params.path; - return await MyPage.findOne({ idapp, path: mypath }).then((ris) => { - return res.send({ mypage: ris }); + let found = await MyPage.findOne({ idapp, path: mypath }).then((ris) => { + if (ris) + return res.send({ mypage: ris }); + else + return null; }).catch((e) => { console.log(e.message); res.status(400).send(e); }); + if (!found) { + // trova quelli con il : + let regexp = new RegExp(`:`, 'ig') + const searchpagesSpec = await MyPage.find({ idapp, path: { $regex: regexp } }); + + if (searchpagesSpec) { + let arrsubpath = mypath.split('/'); + for (let i = 0; i < searchpagesSpec.length; i++) { + let arrsubstr = searchpagesSpec[i].path.split('/'); + + if (arrsubpath.length === arrsubpath.length) { + + let mypathbuild = ''; + + for (let j = 0; j < arrsubstr.length; j++) { + if (arrsubstr[j].includes(':')) { + mypathbuild += arrsubpath[j] + '/'; + } else { + mypathbuild += arrsubstr[j] + '/'; + } + } + + if (mypath + '/' === mypathbuild) { + return res.send({ mypage: searchpagesSpec[i] }); + } + } + } + } + + return await MyPage.findOne({ idapp, path: mypath }).then((ris) => { + return res.send({ mypage: ris }); + }); + } + return found; });