mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 01:15:47 +01:00
closes #3311
This commit is contained in:
@@ -125,25 +125,31 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
function togglePin(tid, uid, pin, callback) {
|
||||
topics.getTopicFields(tid, ['cid', 'lastposttime'], function(err, topicData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
var topicData;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
topics.getTopicFields(tid, ['cid', 'lastposttime'], next);
|
||||
},
|
||||
function(_topicData, next) {
|
||||
topicData = _topicData;
|
||||
async.parallel([
|
||||
async.apply(topics.setTopicField, tid, 'pinned', pin ? 1 : 0),
|
||||
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', pin ? Math.pow(2, 53) : topicData.lastposttime, tid)
|
||||
], next);
|
||||
},
|
||||
function(results, next) {
|
||||
var data = {
|
||||
tid: tid,
|
||||
isPinned: pin,
|
||||
uid: uid,
|
||||
cid: topicData.cid
|
||||
};
|
||||
|
||||
plugins.fireHook('action:topic.pin', data);
|
||||
|
||||
next(null, data);
|
||||
}
|
||||
|
||||
topics.setTopicField(tid, 'pinned', pin ? 1 : 0);
|
||||
db.sortedSetAdd('cid:' + topicData.cid + ':tids', pin ? Math.pow(2, 53) : topicData.lastposttime, tid);
|
||||
|
||||
var data = {
|
||||
tid: tid,
|
||||
isPinned: pin,
|
||||
uid: uid,
|
||||
cid: topicData.cid
|
||||
};
|
||||
|
||||
plugins.fireHook('action:topic.pin', data);
|
||||
|
||||
callback(null, data);
|
||||
});
|
||||
], callback);
|
||||
}
|
||||
|
||||
ThreadTools.move = function(tid, cid, uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user