2022-09-14 11:32:04 +02:00
|
|
|
const mongoose = require('mongoose').set('debug', false)
|
2021-04-30 01:31:12 +02:00
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
const tools = require('../tools/general');
|
|
|
|
|
|
|
|
|
|
mongoose.Promise = global.Promise;
|
|
|
|
|
mongoose.level = "F";
|
|
|
|
|
|
2022-09-14 11:32:04 +02:00
|
|
|
mongoose.set('debug', false);
|
2021-09-22 01:13:41 +02:00
|
|
|
|
2021-04-30 01:31:12 +02:00
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
|
|
|
mongoose.plugin(schema => {
|
|
|
|
|
schema.options.usePushEach = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const SiteSchema = new Schema({
|
|
|
|
|
active: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
idapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
adminemail: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
manageremail: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
replyTo: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
host: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-01-07 01:18:01 +01:00
|
|
|
host_test: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
portapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
dir: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-01-07 01:18:01 +01:00
|
|
|
dir_test: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
email_from: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
email_pwd: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
telegram_key: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
telegram_bot_name: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-01-07 01:18:01 +01:00
|
|
|
telegram_key_test: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
telegram_bot_name_test: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-02-25 17:24:31 +01:00
|
|
|
telegram_support_chat: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
pathreg_add: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-12-21 01:27:45 +01:00
|
|
|
who: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
status: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
note: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
domain_provider: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
domain_expiring: {
|
|
|
|
|
type: Date
|
|
|
|
|
},
|
|
|
|
|
next_payment: {
|
|
|
|
|
type: Date
|
|
|
|
|
},
|
2022-11-17 08:09:48 +01:00
|
|
|
description: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
keywords: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-11-23 10:27:27 +01:00
|
|
|
confpages: {
|
|
|
|
|
font: { type: String },
|
|
|
|
|
col_toolbar: { type: String },
|
|
|
|
|
col_bgfooter: { type: String },
|
2022-11-23 23:57:06 +01:00
|
|
|
show_darkopt: { type: Boolean },
|
2022-11-23 10:27:27 +01:00
|
|
|
},
|
2022-02-27 16:56:02 +01:00
|
|
|
confsite: {
|
|
|
|
|
options: { // ConfSite
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0,
|
|
|
|
|
},
|
2022-11-18 18:54:18 +01:00
|
|
|
},
|
2022-11-23 10:27:27 +01:00
|
|
|
policy: {
|
|
|
|
|
show: { type: Boolean },
|
|
|
|
|
owneremail: { type: String },
|
|
|
|
|
siteName: { type: String },
|
|
|
|
|
ownerDataName: { type: String },
|
|
|
|
|
managerData: { type: String },
|
|
|
|
|
includeData: { type: String },
|
|
|
|
|
url: { type: String },
|
|
|
|
|
lastdataupdate: { type: String },
|
|
|
|
|
country: { type: String },
|
|
|
|
|
},
|
2022-11-18 18:54:18 +01:00
|
|
|
contacts: {
|
2022-11-23 10:27:27 +01:00
|
|
|
facebook: { type: String },
|
|
|
|
|
instagram: { type: String },
|
|
|
|
|
whatsapp: { type: String },
|
|
|
|
|
whatsapp_home: { type: Boolean },
|
|
|
|
|
telegram: { type: String },
|
|
|
|
|
youtube: { type: String },
|
|
|
|
|
email: { type: String },
|
|
|
|
|
address: { type: String },
|
|
|
|
|
map: { type: String },
|
|
|
|
|
info2: { type: String },
|
|
|
|
|
cell: { type: String },
|
|
|
|
|
},
|
|
|
|
|
footer_mobile: {
|
|
|
|
|
show_buttHome: { type: Boolean },
|
|
|
|
|
show_profile: { type: Boolean },
|
2022-11-18 18:54:18 +01:00
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var Site = module.exports = mongoose.model('Site', SiteSchema);
|
|
|
|
|
|
|
|
|
|
module.exports.getFieldsForSearch = function () {
|
|
|
|
|
return []
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-27 16:56:02 +01:00
|
|
|
module.exports.executeQueryTable = async function (idapp, params, userreq) {
|
2021-04-30 01:31:12 +02:00
|
|
|
params.fieldsearch = this.getFieldsForSearch();
|
|
|
|
|
// return tools.executeQueryTable(this, null, params);
|
|
|
|
|
|
2022-02-27 16:56:02 +01:00
|
|
|
const { User } = require('../models/user');
|
|
|
|
|
|
|
|
|
|
// Solo l'Admin puó leggerlo
|
|
|
|
|
|
|
|
|
|
const extrapar = params.extrapar;
|
|
|
|
|
|
|
|
|
|
if (extrapar) {
|
2022-11-17 08:09:48 +01:00
|
|
|
if (User.isManager(userreq.perm)) {
|
|
|
|
|
return await Site.findOne({ idapp: extrapar }).lean();
|
|
|
|
|
} else {
|
|
|
|
|
return await Site.findOne({ idapp: extrapar }, {
|
|
|
|
|
name: 1, manageremail: 1,
|
|
|
|
|
confsite: 1,
|
|
|
|
|
description: 1,
|
|
|
|
|
keywords: 1,
|
|
|
|
|
}).lean();
|
|
|
|
|
}
|
2022-02-27 16:56:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (User.isAdmin(userreq.perm)) {
|
|
|
|
|
const myarr = await Site.find({});
|
|
|
|
|
|
2022-11-17 08:09:48 +01:00
|
|
|
// return await Site.find({}).lean();
|
2022-02-27 16:56:02 +01:00
|
|
|
return ({ count: myarr.length, rows: myarr })
|
2021-04-30 01:31:12 +02:00
|
|
|
|
2022-02-27 16:56:02 +01:00
|
|
|
}
|
2021-04-30 01:31:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-05 00:38:41 +02:00
|
|
|
module.exports.findAll = async function () {
|
2021-04-30 01:31:12 +02:00
|
|
|
|
|
|
|
|
const myfind = { active: true };
|
|
|
|
|
|
2022-07-23 17:48:33 +02:00
|
|
|
return await Site.find(myfind).lean();
|
2021-09-22 01:13:41 +02:00
|
|
|
|
2021-04-30 01:31:12 +02:00
|
|
|
};
|
2022-05-05 00:38:41 +02:00
|
|
|
|
|
|
|
|
module.exports.findAllIdApp = async function (idapp) {
|
|
|
|
|
|
|
|
|
|
const myfind = { idapp, active: true };
|
|
|
|
|
|
|
|
|
|
let rec = await Site.findOne(myfind).lean();
|
|
|
|
|
if (rec) {
|
|
|
|
|
|
|
|
|
|
rec.email_pwd = '';
|
|
|
|
|
rec.telegram_key = '';
|
|
|
|
|
rec.telegram_key_test = '';
|
|
|
|
|
|
|
|
|
|
return rec;
|
|
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
};
|