-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlibrary.js
More file actions
42 lines (24 loc) · 923 Bytes
/
library.js
File metadata and controls
42 lines (24 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
var User = module.parent.require('./user');
var Topic = module.parent.require('./topics');
var ThreadTools = module.parent.require('./threadTools');
var Post = module.parent.require('./posts');
var SocketAdmins = module.parent.require('./socket.io/admin');
var db = module.parent.require('./database');
var Utils = module.parent.require('../public/src/utils')
var plugin = {};
plugin.lockTopic = function (data, callback) {
//configure your thread limit
var limit = 1000;
//console.log(data);
// ThreadTools.lock(topicObj.tid, 0, next);
Post.getPidIndex(data.pid, data.uid, function(err, index){
//console.log(index);
if( !err && index >= limit )
{ // if no error and the index >= limit -> LOCK
console.log("Locking topic: "+ data.tid);
ThreadTools.lock(data.tid, 0, callback);
}
});
};
module.exports = plugin;