wip flagged posts
parent
0bea912077
commit
086e99de5c
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
|
||||
|
||||
var posts = require('../posts');
|
||||
|
||||
|
||||
var postsController = {};
|
||||
|
||||
postsController.flagged = function(req, res, next) {
|
||||
function done(err, posts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('admin/manage/flags', {posts: posts, next: stop + 1, byUsername: byUsername});
|
||||
}
|
||||
|
||||
var sortBy = req.query.sortBy || 'count';
|
||||
var byUsername = req.query.byUsername || '';
|
||||
var start = 0;
|
||||
var stop = 19;
|
||||
|
||||
if (byUsername) {
|
||||
posts.getUserFlags(byUsername, sortBy, req.uid, start, stop, done);
|
||||
} else {
|
||||
var set = sortBy === 'count' ? 'posts:flags:count' : 'posts:flagged';
|
||||
posts.getFlags(set, req.uid, start, stop, done);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = postsController;
|
Loading…
Reference in New Issue