diff --git a/src/controllers/navRender.js b/src/controllers/navRender.js
index 53fc198..57dc8ca 100644
--- a/src/controllers/navRender.js
+++ b/src/controllers/navRender.js
@@ -19,6 +19,7 @@ const config = require('../../config.json');
//Local Imports
const csrfUtils = require('../utils/csrfUtils');
+const presenceUtils = require('../utils/presenceUtils');
/* You could make the argument this should be middleware that passes a properties object to user
But then I'd writing out all the other controllers properties as I am below, or worse. Not a great option.*/
@@ -30,6 +31,7 @@ module.exports.render = async function(req, res, template, properties = {}){
properties.links = config.links;
properties.user = req.session.user
properties.csrfToken = csrfUtils.generateToken(req)
+ properties.userCount = (await presenceUtils.getOnlineUsers()).length;
//Render out template, passing given properties with navbar required properties added
return res.render(template, properties);
diff --git a/src/utils/presenceUtils.js b/src/utils/presenceUtils.js
index 87acb97..35326ba 100644
--- a/src/utils/presenceUtils.js
+++ b/src/utils/presenceUtils.js
@@ -28,6 +28,26 @@ const tolerance = 2 * (60 * 1000);
//Defaults to five minutes
const offlineTimeout = 5 * (60 * 1000);
+module.exports.getOnlineUsers = async function(){
+ //Define array to hold list of online users
+ const users = [];
+
+ //Iterate through all users in the RAM-Backed activity map (only ones that would be online)
+ for(const key of Array.from(activityMap.keys())){
+ //Grab current user, should grab from ram since we're polling activityMap
+ const user = await module.exports.getPresence(key);
+
+ //If the user is online
+ if(user.status == "Streaming" || user.status == "Recently Active"){
+ //Addem' to da list
+ users.push(user);
+ }
+ }
+
+ //Return all found users
+ return users;
+}
+
module.exports.getPresence = async function(user, userDB){
//If we don't have a user
if(user == null || user == '' || user == 'Tokebot'){
@@ -44,7 +64,7 @@ module.exports.getPresence = async function(user, userDB){
//If we couldn't find anything in RAM
if(activity == null){
- //If we wheren't handed a free user doc
+ //If we wheren't handed a free user doc, and we're allowed to pull from DB
if(userDB == null){
//Pull one from the username
userDB = await userModel.findOne({user: user});
diff --git a/src/views/partial/navbar.ejs b/src/views/partial/navbar.ejs
index db80667..696805b 100644
--- a/src/views/partial/navbar.ejs
+++ b/src/views/partial/navbar.ejs
@@ -14,28 +14,33 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see