From 6b128ec798c732ada96eda07ccf8cadc3ef447e7 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 31 Aug 2013 12:53:45 +0000 Subject: [PATCH] finish [#578] --- modules/report/pages.js | 86 +++++++++++++++++++------------------- views/report/channels.jade | 6 ++- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/modules/report/pages.js b/modules/report/pages.js index 8e5ea7d..70f833e 100644 --- a/modules/report/pages.js +++ b/modules/report/pages.js @@ -45,8 +45,50 @@ var pages = function(dbot) { }); }, - '/notify/:server/missing': function(req, res) { - var server = req.params.server, + '/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.search('notifies', { 'server': req.user.server, 'channel': cName }, function(notify) { + notifications.push(notify); + }, function() { + done(); + }); + }.bind(this), 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 + }); + }); + }.bind(this)); + }.bind(this)); + }, + + '/notify/missing': function(req, res) { + var server = req.user.server, user = req.user, notifies = this.pending[user.id]; @@ -133,46 +175,6 @@ var pages = function(dbot) { } }, - '/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 - }); - }); - }); - }); - } }; return pages; diff --git a/views/report/channels.jade b/views/report/channels.jade index 7cf5dcd..3edc3bd 100644 --- a/views/report/channels.jade +++ b/views/report/channels.jade @@ -3,6 +3,10 @@ extends ../layout block content div#backlink a(href='/') « Home + h3 + a(href='/notify/stream') My Notification Stream + | + a(href='/notify/missing') My Missed Notifications h3 Browse by Channel on #{server} ul#quotelist -each count, name in channels @@ -14,5 +18,3 @@ block content -each nUser in users a(href='/notify/'+encodeURIComponent(nUser.name)) li.quotes #{nUser.name} (#{nUser.count}) - h3 - a(href='/notify/missing') My Missed Notifications