Skip to content

Node.js based forum software built for the modern web

get recent poster uids

barisusaklie8b767d0dd37
diff --git a/src/posts.js b/src/posts.js
index c6869b180b..9e06528f2b 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -188,6 +188,36 @@ var async = require('async'),
});
};
+ Posts.getRecentPosterUids = function(start, end, callback) {
+ db.getSortedSetRevRange('posts:pid', start, end, function(err, pids) {
+ if (err) {
+ return callback(err);
+ }
+
+ if (!Array.isArray(pids) || !pids.length) {
+ return callback(null, []);
+ }
+
+ pids = pids.map(function(pid) {
+ return 'post:' + pid;
+ });
+
+ db.getObjectsFields(pids, ['uid'], function(err, postData) {
+ if (err) {
+ return callback(err);
+ }
+
+ postData = postData.map(function(post) {
+ return post && post.uid;
+ }).filter(function(value, index, array) {
+ return value && array.indexOf(value) === index;
+ });
+
+ callback(null, postData);
+ });
+ });
+ };
+
Posts.getUserInfoForPosts = function(uids, callback) {
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
if (err) {