mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
moved get_last_undeleted_pid to threadTools.js
This commit is contained in:
@@ -3,7 +3,8 @@ var RDB = require('./redis.js'),
|
||||
categories = require('./categories.js'),
|
||||
user = require('./user.js'),
|
||||
async = require('async'),
|
||||
notifications = require('./notifications.js');
|
||||
notifications = require('./notifications.js'),
|
||||
posts = require('./posts');
|
||||
|
||||
(function(ThreadTools) {
|
||||
|
||||
@@ -266,4 +267,23 @@ var RDB = require('./redis.js'),
|
||||
});
|
||||
}
|
||||
|
||||
ThreadTools.get_latest_undeleted_pid = function(tid, callback) {
|
||||
|
||||
posts.getPostsByTid(tid, 0, -1, function(posts) {
|
||||
|
||||
var numPosts = posts.length;
|
||||
if(!numPosts)
|
||||
return callback(new Error('no-undeleted-pids-found'));
|
||||
|
||||
while(numPosts--) {
|
||||
if(posts[numPosts].deleted !== '1') {
|
||||
callback(null, posts[numPosts].pid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got here, nothing was found...
|
||||
callback(new Error('no-undeleted-pids-found'));
|
||||
});
|
||||
}
|
||||
}(exports));
|
||||
Reference in New Issue
Block a user