mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-21 21:26:00 -05:00
debugging systems list
This commit is contained in:
@@ -15,7 +15,7 @@ const mailjet = new Mailjet({
|
||||
var systemList = [];
|
||||
var systemListTime = Date.now();
|
||||
|
||||
exports.contact_system = async function(req, res) {
|
||||
exports.contact_system = async function (req, res) {
|
||||
var system = await System.findOne({
|
||||
shortName: req.params.shortName.toLowerCase()
|
||||
}).catch(err => {
|
||||
@@ -72,7 +72,7 @@ exports.contact_system = async function(req, res) {
|
||||
To: [{
|
||||
Email: user.email,
|
||||
Name: user.firstName + " " + user.lastName
|
||||
},{
|
||||
}, {
|
||||
Email: admin_email,
|
||||
Name: site_name + " Admin"
|
||||
}],
|
||||
@@ -102,7 +102,7 @@ exports.contact_system = async function(req, res) {
|
||||
|
||||
async function load_systems(systemClients) {
|
||||
let fromDate = new Date(Date.now() - 60 * 60 * 24 * 30 * 1000);
|
||||
const results = await System.find({lastActive: {$gte: fromDate}}).populate('userId', "screenName").catch( err => {
|
||||
const results = await System.find({ lastActive: { $gte: fromDate } }).populate('userId', "screenName").catch(err => {
|
||||
//const results = await System.find({active: true}).populate('userId', "screenName").catch( err => {
|
||||
//const results = await System.find({active: true}).catch( err => { // super simple query
|
||||
console.error("Error - get_systems: " + err.message);
|
||||
@@ -139,12 +139,12 @@ async function load_systems(systemClients) {
|
||||
system.screenName = null;
|
||||
systemList.push(system);
|
||||
}
|
||||
|
||||
console.log("Loaded Systems: " + systemList.length + " that have been active since: " + fromDate);
|
||||
}
|
||||
|
||||
|
||||
exports.get_systems = async function (req, res) {
|
||||
if ((systemList.length == 0) || (systemListTime < (Date.now() - 60 * 1000 * 15))) {
|
||||
if ((systemList.length == 0) || (systemListTime < (Date.now() - 60 * 1000 * 2))) {
|
||||
await load_systems(req.systemClients);
|
||||
systemListTime = Date.now();
|
||||
}
|
||||
@@ -154,9 +154,9 @@ exports.get_systems = async function (req, res) {
|
||||
success: true,
|
||||
systems: systemList
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
exports.authorize_system = async function (req, res) {
|
||||
exports.authorize_system = async function (req, res) {
|
||||
|
||||
var shortName = req.params.shortName.toLowerCase();
|
||||
var apiKey = req.body.api_key;
|
||||
@@ -188,5 +188,5 @@ exports.get_systems = async function (req, res) {
|
||||
res.status(200).end();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user