From 13c0afbc1ee13d2fc847f772c6dad805a1e110df Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 4 Aug 2022 11:28:28 -0700 Subject: [PATCH] Improved error message if the server can't read session recordings. (#4363) --- meshuser.js | 6 +++--- views/default.handlebars | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/meshuser.js b/meshuser.js index 3dea9278..7c0a9bac 100644 --- a/meshuser.js +++ b/meshuser.js @@ -1025,11 +1025,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (domain.sessionrecording.filepath) { recordingsPath = domain.sessionrecording.filepath; } else { recordingsPath = parent.parent.recordpath; } if (recordingsPath == null) return; fs.readdir(recordingsPath, function (err, files) { - if (err != null) return; + if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 1, tag: command.tag })); } catch (ex) { } return; } if ((command.limit == null) || (typeof command.limit != 'number')) { // Send the list of all recordings db.GetEvents(['recording'], domain.id, function (err, docs) { - if (err != null) return; + if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 2, tag: command.tag })); } catch (ex) { } return; } for (var i in docs) { delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these. if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; } @@ -1039,7 +1039,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } else { // Send the list of most recent recordings, up to 'limit' count db.GetEventsWithLimit(['recording'], domain.id, command.limit, function (err, docs) { - if (err != null) return; + if (err != null) { try { ws.send(JSON.stringify({ action: 'recordings', error: 2, tag: command.tag })); } catch (ex) { } return; } for (var i in docs) { delete docs[i].action; delete docs[i].etype; delete docs[i].msg; // TODO: We could make a more specific query in the DB and never have these. if (files.indexOf(docs[i].filename) >= 0) { docs[i].present = 1; } diff --git a/views/default.handlebars b/views/default.handlebars index 21f5ebce..6e98a115 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2728,6 +2728,7 @@ } case 'recordings': { p52recordings = message.events; + if (message.error != null) { p52recordings = message.error; } updateRecordings(); break; } @@ -2986,7 +2987,7 @@ break; } case 'recording': { - if (p52recordings != null) { p52recordings.unshift(message.event); message.event.present = 1; updateRecordings(); } + if ((p52recordings != null) && (typeof p52recordings == 'object')) { p52recordings.unshift(message.event); message.event.present = 1; updateRecordings(); } break; } case 'userWebState': { @@ -15943,6 +15944,10 @@ if (p52recordings == null) { x += '
' + "Loading..." + '
'; + } else if (typeof p52recordings == 'number') { + if (p52recordings == 1) { x += '
' + "Server is unable to read from the recordings folder." + '
'; } + else if (p52recordings == 2) { x += '
' + "Server is unable to get recordings from the database." + '
'; } + else { x += '
' + "An unknown error occured." + '
'; } } else if (p52recordings.length == 0) { x += '
' + "No recordings." + '
'; } else {