From 213f63ae1272b249609e75ebf09a7da31cd83035 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 2 Mar 2017 18:50:58 -0700 Subject: [PATCH] More deleted user robustness --- core/user.js | 4 ++-- mods/last_callers.js | 32 ++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/user.js b/core/user.js index 5d85c5b4..15e5a844 100644 --- a/core/user.js +++ b/core/user.js @@ -489,8 +489,8 @@ module.exports = class User { return cb(err); } properties[row.prop_name] = row.prop_value; - }, () => { - return cb(null, properties); + }, (err) => { + return cb(err, err ? null : properties); }); } diff --git a/mods/last_callers.js b/mods/last_callers.js index 3e37a22b..afb429d8 100644 --- a/mods/last_callers.js +++ b/mods/last_callers.js @@ -105,21 +105,29 @@ exports.getModule = class LastCallersModule extends MenuModule { item.ts = moment(item.timestamp).format(dateTimeFormat); User.getUserName(item.userId, (err, userName) => { - item.userName = userName || 'N/A'; + if(err) { + item.deleted = true; + return next(null); + } else { + item.userName = userName || 'N/A'; - User.loadProperties(item.userId, getPropOpts, (err, props) => { - if(!err) { - item.location = props.location; - item.affiliation = item.affils = props.affiliation; - } else { - item.location = 'N/A'; - item.affiliation = item.affils = 'N/A'; - } - return next(); - }); + User.loadProperties(item.userId, getPropOpts, (err, props) => { + if(!err && props) { + item.location = props.location || 'N/A'; + item.affiliation = item.affils = (props.affiliation || 'N/A'); + } else { + item.location = 'N/A'; + item.affiliation = item.affils = 'N/A'; + } + return next(null); + }); + } }); }, - callback + err => { + loginHistory = loginHistory.filter(lh => true !== lh.deleted); + return callback(err); + } ); }, function populateList(callback) {