mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 17:27:37 -05:00
last try
This commit is contained in:
@@ -56,11 +56,11 @@ const connect = () => {
|
|||||||
mongoose.connect(secrets.db).then((result) => { // Successfully connected
|
mongoose.connect(secrets.db).then((result) => { // Successfully connected
|
||||||
console.log("connected to Mongo");
|
console.log("connected to Mongo");
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// Catch any potential error
|
// Catch any potential error
|
||||||
console.log(mongoose.version);
|
console.log(mongoose.version);
|
||||||
console.log("Unable to connect to MongoDB. Error: " + err);
|
console.log("Unable to connect to MongoDB. Error: " + err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
@@ -259,33 +259,34 @@ io.sockets.on('connection', function (client) {
|
|||||||
clients[client.id].timestamp = new Date();
|
clients[client.id].timestamp = new Date();
|
||||||
if ((data.filterType == "group") && (data.filterCode.indexOf(',') == -1)) {
|
if ((data.filterType == "group") && (data.filterCode.indexOf(',') == -1)) {
|
||||||
const groupCollection = db.get().collection("groups");
|
const groupCollection = db.get().collection("groups");
|
||||||
if (!groupCollection) {
|
if (!groupCollection) {
|
||||||
console.error("Error - unable to open groups collection: " + err);
|
console.error("Error - unable to open groups collection: " + err);
|
||||||
delete clients[client.id];
|
delete clients[client.id];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ObjectId.isValid(data.filterCode)) {
|
if (!ObjectId.isValid(data.filterCode)) {
|
||||||
console.error("Error - Socket - Invalid Group ID: " + data.filterCode);
|
console.error("Error - Socket - Invalid Group ID: " + data.filterCode);
|
||||||
delete clients[client.id];
|
delete clients[client.id];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
let group;
|
||||||
const group = await groupCollection.findOne({
|
try {
|
||||||
|
group = await groupCollection.findOne({
|
||||||
'shortName': data.shortName.toLowerCase(),
|
'shortName': data.shortName.toLowerCase(),
|
||||||
'_id': ObjectId.createFromHexString(data.filterCode)
|
'_id': ObjectId.createFromHexString(data.filterCode)
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn("[" + data.shortName.toLowerCase() + "] Error - WebSocket Group ID not Found! Error: " + err + " Group ID: " + data.filterCode);
|
console.warn("[" + data.shortName.toLowerCase() + "] Error - WebSocket Group ID not Found! Error: " + err + " Group ID: " + data.filterCode);
|
||||||
delete clients[client.id];
|
delete clients[client.id];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (group && clients[client.id]) {
|
if (group && clients[client.id]) {
|
||||||
clients[client.id].talkgroupNums = group.talkgroups;
|
clients[client.id].talkgroupNums = group.talkgroups;
|
||||||
} else {
|
} else {
|
||||||
console.error("Error - Socket: Invalid group or Client: " + data.filterCode + " Shortname: " + data.shortName + " ClientID: " + client.id);
|
console.error("Error - Socket: Invalid group or Client: " + data.filterCode + " Shortname: " + data.shortName + " ClientID: " + client.id);
|
||||||
delete clients[client.id];
|
delete clients[client.id];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((data.filterType == "talkgroup") && Array.isArray(data.filterCode)) {
|
} else if ((data.filterType == "talkgroup") && Array.isArray(data.filterCode)) {
|
||||||
clients[client.id].talkgroupNums = data.filterCode;
|
clients[client.id].talkgroupNums = data.filterCode;
|
||||||
|
|||||||
Reference in New Issue
Block a user