mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-11 08:17:29 -05:00
catching more errors
This commit is contained in:
@@ -6,7 +6,7 @@ var Talkgroup = require("../models/talkgroup");
|
||||
var { callModel: Call } = require("../models/call");
|
||||
|
||||
const { PutObjectCommand, S3Client } = require("@aws-sdk/client-s3");
|
||||
const {fromIni} = require("@aws-sdk/credential-providers");
|
||||
const { fromIni } = require("@aws-sdk/credential-providers");
|
||||
|
||||
var s3_endpoint = process.env['S3_ENDPOINT'] != null ? process.env['S3_ENDPOINT'] : 'https://s3.us-west-1.wasabisys.com';
|
||||
var s3_region = process.env['S3_REGION'] != null ? process.env['S3_REGION'] : 'us-west-1';
|
||||
@@ -144,9 +144,13 @@ exports.upload = async function (req, res, next) {
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
var s3Src = fs.createReadStream(req.file.path);
|
||||
|
||||
let s3Src;
|
||||
try {
|
||||
s3Src = fs.createReadStream(req.file.path);
|
||||
} catch (err) {
|
||||
console.error("[" + call.shortName + "] Unable to open file: " + req.file.path)
|
||||
return;
|
||||
}
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: s3_bucket,
|
||||
Key: object_key,
|
||||
|
||||
@@ -247,7 +247,7 @@ function notify_clients(call) {
|
||||
io.sockets.on('connection', function (client) {
|
||||
clients[client.id] = { socket: client, active: false };
|
||||
clients[client.id].timestamp = new Date();
|
||||
client.on('start', function (data) {
|
||||
client.on('start', async function (data) {
|
||||
if (clients[client.id] && data.shortName) {
|
||||
clients[client.id].active = true;
|
||||
clients[client.id].shortName = data.shortName.toLowerCase();
|
||||
@@ -258,8 +258,8 @@ io.sockets.on('connection', function (client) {
|
||||
clients[client.id].talkgroupNums = [];
|
||||
clients[client.id].timestamp = new Date();
|
||||
if ((data.filterType == "group") && (data.filterCode.indexOf(',') == -1)) {
|
||||
db.get().collection("groups", function (err, groupCollection) {
|
||||
if (err || !groupCollection) {
|
||||
const groupCollection = db.get().collection("groups");
|
||||
if (!groupCollection) {
|
||||
console.error("Error - unable to open groups collection: " + err);
|
||||
delete clients[client.id];
|
||||
return;
|
||||
@@ -269,15 +269,16 @@ io.sockets.on('connection', function (client) {
|
||||
delete clients[client.id];
|
||||
return;
|
||||
}
|
||||
groupCollection.findOne({
|
||||
try {
|
||||
const group = await groupCollection.findOne({
|
||||
'shortName': data.shortName.toLowerCase(),
|
||||
'_id': ObjectId.createFromHexString(data.filterCode)
|
||||
}, function (err, group) {
|
||||
if (err) {
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn("[" + data.shortName.toLowerCase() + "] Error - WebSocket Group ID not Found! Error: " + err + " Group ID: " + data.filterCode);
|
||||
delete clients[client.id];
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
if (group && clients[client.id]) {
|
||||
clients[client.id].talkgroupNums = group.talkgroups;
|
||||
} else {
|
||||
@@ -285,11 +286,8 @@ io.sockets.on('connection', function (client) {
|
||||
delete clients[client.id];
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} if ((data.filterType == "talkgroup") && Array.isArray(data.filterCode)) {
|
||||
|
||||
} else if ((data.filterType == "talkgroup") && Array.isArray(data.filterCode)) {
|
||||
clients[client.id].talkgroupNums = data.filterCode;
|
||||
}
|
||||
//console.log("[" + data.shortName.toLowerCase() + "] WebSocket Updating - Client: " + client.id + " code set to: " + data.filterCode + " type set to: " + data.filterType + " TGS: " + clients[client.id].talkgroupNums);
|
||||
|
||||
Reference in New Issue
Block a user