From 8e4ac8d503533cde1c34e814ce5bb27e6f9de88f Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 31 Aug 2013 12:38:25 +0000 Subject: [PATCH] do that thing wot i said for [#578] --- modules/report/pages.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/report/pages.js b/modules/report/pages.js index 5de5d52..8e5ea7d 100644 --- a/modules/report/pages.js +++ b/modules/report/pages.js @@ -131,6 +131,47 @@ var pages = function(dbot) { }); }.bind(this)); } + }, + + '/notify/stream': function(req, res) { + var staffedChannels = [], + notifications = []; + async.each(req.user.channels, function(cId, done) { + dbot.api.users.getChannel(cId, function(channel) { + if(_.include(channel.op, req.user.id) || + (this.config.notifyVoice && _.include(channel.voice, req.user.id))) { + staffedChannels.push(channel.name); + } + done(); + }.bind(this)); + }.bind(this), function() { + async.each(staffedChannels, function(cName, done) { + this.db.scan('notifies', { 'server': req.user.server, 'channel': cName }, function(notify) { + notifications.push(notify); + }, function() { + done(); + }); + }, function() { + async.each(notifications, function(notify, done) { + dbot.api.users.getUser(notify.user, function(user) { + if(user) notify.user = user.primaryNick; + done(); + }); + }, function() { + notifications = _.sortBy(notifications, 'time').reverse(); + if(req.user.timezone) { + _.each(notifications, function(v, k) { + v.time = moment(v.time).tz(req.user.timezone); + }); + } + + res.render('notifies', { + 'server': req.user.server, + 'notifies': notifications + }); + }); + }); + }); } };