|
|
|
@ -47,9 +47,7 @@ var RDB = require('./redis.js'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.lock = function(tid, uid, socket) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
ThreadTools.lock = function(tid, socket) {
|
|
|
|
|
topics.setTopicField(tid, 'locked', 1);
|
|
|
|
|
|
|
|
|
|
if (socket) {
|
|
|
|
@ -64,12 +62,8 @@ var RDB = require('./redis.js'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.unlock = function(tid, uid, socket) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
ThreadTools.unlock = function(tid, socket) {
|
|
|
|
|
topics.setTopicField(tid, 'locked', 0);
|
|
|
|
|
|
|
|
|
|
if (socket) {
|
|
|
|
@ -84,18 +78,13 @@ var RDB = require('./redis.js'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.delete = function(tid, uid, callback) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable || uid === -1) {
|
|
|
|
|
|
|
|
|
|
ThreadTools.delete = function(tid, callback) {
|
|
|
|
|
topics.delete(tid);
|
|
|
|
|
|
|
|
|
|
RDB.decr('totaltopiccount');
|
|
|
|
|
|
|
|
|
|
ThreadTools.lock(tid, uid);
|
|
|
|
|
ThreadTools.lock(tid);
|
|
|
|
|
|
|
|
|
|
topicSearch.remove(tid);
|
|
|
|
|
|
|
|
|
@ -104,18 +93,15 @@ var RDB = require('./redis.js'),
|
|
|
|
|
status: 'ok'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback(null);
|
|
|
|
|
} else callback(new Error('not-enough-privs'));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.restore = function(tid, uid, socket, callback) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
|
|
|
|
|
ThreadTools.restore = function(tid, socket, callback) {
|
|
|
|
|
topics.restore(tid);
|
|
|
|
|
RDB.incr('totaltopiccount');
|
|
|
|
|
ThreadTools.unlock(tid, uid);
|
|
|
|
|
ThreadTools.unlock(tid);
|
|
|
|
|
|
|
|
|
|
io.sockets.in('topic_' + tid).emit('event:topic_restored', {
|
|
|
|
|
tid: tid,
|
|
|
|
@ -126,16 +112,12 @@ var RDB = require('./redis.js'),
|
|
|
|
|
topicSearch.index(title, tid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(callback)
|
|
|
|
|
if(callback) {
|
|
|
|
|
callback(null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.pin = function(tid, uid, socket) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
|
|
|
|
|
ThreadTools.pin = function(tid, socket) {
|
|
|
|
|
topics.setTopicField(tid, 'pinned', 1);
|
|
|
|
|
topics.getTopicField(tid, 'cid', function(err, cid) {
|
|
|
|
|
RDB.zadd('categories:' + cid + ':tid', Math.pow(2, 53), tid);
|
|
|
|
@ -153,13 +135,8 @@ var RDB = require('./redis.js'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.unpin = function(tid, uid, socket) {
|
|
|
|
|
ThreadTools.privileges(tid, uid, function(privileges) {
|
|
|
|
|
if (privileges.editable) {
|
|
|
|
|
|
|
|
|
|
ThreadTools.unpin = function(tid, socket) {
|
|
|
|
|
topics.setTopicField(tid, 'pinned', 0);
|
|
|
|
|
topics.getTopicFields(tid, ['cid', 'lastposttime'], function(err, topicData) {
|
|
|
|
|
RDB.zadd('categories:' + topicData.cid + ':tid', topicData.lastposttime, tid);
|
|
|
|
@ -176,8 +153,6 @@ var RDB = require('./redis.js'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ThreadTools.move = function(tid, cid, socket) {
|
|
|
|
|
|
|
|
|
|