From bdeb7b13f1516ba4a4c9fef12767d7070035fb03 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 16 May 2013 12:49:39 -0400 Subject: [PATCH] interim commit for moderator support --- public/templates/category.tpl | 10 ++++++++++ src/categories.js | 14 ++++++++++++++ src/posts.js | 3 ++- src/templates.js | 2 +- src/topics.js | 16 ++++++++++------ src/user.js | 6 ++++++ src/webserver.js | 4 ++-- 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 147bf46267..85aa47df9c 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -50,6 +50,16 @@ + diff --git a/src/categories.js b/src/categories.js index 1ac673d262..5f35dc1d14 100644 --- a/src/categories.js +++ b/src/categories.js @@ -38,6 +38,20 @@ var RDB = require('./redis.js'), }); } + Categories.getModerators = function(cid, callback) { + RDB.smembers('cid:' + cid + ':moderators', function(err, mods) { + user.getMultipleUserFields(mods, ['username'], function(details) { + var moderators = []; + for(u in details) { + if (details.hasOwnProperty(u)) { + moderators.push({ username: details[u].username }); + } + } + callback(moderators); + }); + }); + } + Categories.get_category = function(cids, callback) { var name = [], description = [], diff --git a/src/posts.js b/src/posts.js index 42a98c83e8..527b07ffe6 100644 --- a/src/posts.js +++ b/src/posts.js @@ -3,7 +3,8 @@ var RDB = require('./redis.js'), marked = require('marked'), user = require('./user.js'), topics = require('./topics.js'), - config = require('../config.js'); + config = require('../config.js'), + async = require('async'); marked.setOptions({ breaks: true diff --git a/src/templates.js b/src/templates.js index 2ad56e23ae..8d04aacf6d 100644 --- a/src/templates.js +++ b/src/templates.js @@ -30,7 +30,7 @@ var fs = require('fs'); Templates.init = function() { loadTemplates([ 'header', 'footer', 'register', 'home', 'topic', 'account', 'friends', - 'login', 'reset', 'reset_code', 'logout', + 'login', 'reset', 'reset_code', '403', 'admin/header', 'admin/footer', 'admin/index', 'emails/header', 'emails/footer', diff --git a/src/topics.js b/src/topics.js index ead41792d1..db1f70dcd8 100644 --- a/src/topics.js +++ b/src/topics.js @@ -81,10 +81,11 @@ var RDB = require('./redis.js'), recent_author = replies[11]; var usernames, - has_read; + has_read, + moderators; function generate_topic() { - if (!usernames || !has_read) return; + if (!usernames || !has_read || !moderators) return; for (var i=0, ii=title.length; i