mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 17:05:51 +01:00
removed bans from downvotes and flags
cleanup thread tools emits
This commit is contained in:
@@ -11,7 +11,6 @@ var winston = require('winston'),
|
||||
notifications = require('./notifications'),
|
||||
posts = require('./posts'),
|
||||
meta = require('./meta'),
|
||||
websockets = require('./socket.io'),
|
||||
events = require('./events'),
|
||||
plugins = require('./plugins'),
|
||||
batch = require('./batch');
|
||||
@@ -39,12 +38,6 @@ var winston = require('winston'),
|
||||
}
|
||||
|
||||
topics[isDelete ? 'delete' : 'restore'](tid, function(err) {
|
||||
function emitTo(room) {
|
||||
websockets.in(room).emit(isDelete ? 'event:topic_deleted' : 'event:topic_restored', {
|
||||
tid: tid,
|
||||
isDelete: isDelete
|
||||
});
|
||||
}
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -56,17 +49,20 @@ var winston = require('winston'),
|
||||
plugins.fireHook('action:topic.restore', topicData);
|
||||
}
|
||||
|
||||
emitTo('topic_' + tid);
|
||||
emitTo('category_' + topicData.cid);
|
||||
var data = {
|
||||
tid: tid,
|
||||
cid: topicData.cid,
|
||||
isDelete: isDelete,
|
||||
uid: uid
|
||||
};
|
||||
|
||||
callback(null, {
|
||||
tid: tid
|
||||
});
|
||||
callback(null, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ThreadTools.purge = function(tid, uid, callback) {
|
||||
var topic;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
topics.exists(tid, next);
|
||||
@@ -80,13 +76,17 @@ var winston = require('winston'),
|
||||
}, {alwaysStartAt: 0}, next);
|
||||
},
|
||||
function(next) {
|
||||
topics.getTopicField(tid, 'mainPid', next);
|
||||
topics.getTopicFields(tid, ['mainPid', 'cid'], next);
|
||||
},
|
||||
function(mainPid, next) {
|
||||
posts.purge(mainPid, next);
|
||||
function(_topic, next) {
|
||||
topic = _topic;
|
||||
posts.purge(topic.mainPid, next);
|
||||
},
|
||||
function(next) {
|
||||
topics.purge(tid, next);
|
||||
},
|
||||
function(next) {
|
||||
next(null, {tid: tid, cid: topic.cid, uid: uid});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
@@ -100,35 +100,24 @@ var winston = require('winston'),
|
||||
};
|
||||
|
||||
function toggleLock(tid, uid, lock, callback) {
|
||||
callback = callback || function() {};
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
function emitTo(room) {
|
||||
websockets.in(room).emit(lock ? 'event:topic_locked' : 'event:topic_unlocked', {
|
||||
tid: tid,
|
||||
isLocked: lock
|
||||
});
|
||||
}
|
||||
|
||||
if (err && typeof callback === 'function') {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
topics.setTopicField(tid, 'locked', lock ? 1 : 0);
|
||||
|
||||
plugins.fireHook('action:topic.lock', {
|
||||
var data = {
|
||||
tid: tid,
|
||||
isLocked: lock,
|
||||
uid: uid
|
||||
});
|
||||
uid: uid,
|
||||
cid: cid
|
||||
};
|
||||
|
||||
emitTo('topic_' + tid);
|
||||
emitTo('category_' + cid);
|
||||
plugins.fireHook('action:topic.lock', data);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback(null, {
|
||||
tid: tid,
|
||||
isLocked: lock
|
||||
});
|
||||
}
|
||||
callback(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,13 +131,6 @@ var winston = require('winston'),
|
||||
|
||||
function togglePin(tid, uid, pin, callback) {
|
||||
topics.getTopicFields(tid, ['cid', 'lastposttime'], function(err, topicData) {
|
||||
function emitTo(room) {
|
||||
websockets.in(room).emit(pin ? 'event:topic_pinned' : 'event:topic_unpinned', {
|
||||
tid: tid,
|
||||
isPinned: pin
|
||||
});
|
||||
}
|
||||
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -156,19 +138,16 @@ var winston = require('winston'),
|
||||
topics.setTopicField(tid, 'pinned', pin ? 1 : 0);
|
||||
db.sortedSetAdd('cid:' + topicData.cid + ':tids', pin ? Math.pow(2, 53) : topicData.lastposttime, tid);
|
||||
|
||||
plugins.fireHook('action:topic.pin', {
|
||||
var data = {
|
||||
tid: tid,
|
||||
isPinned: pin,
|
||||
uid: uid
|
||||
});
|
||||
uid: uid,
|
||||
cid: topicData.cid
|
||||
};
|
||||
|
||||
emitTo('topic_' + tid);
|
||||
emitTo('category_' + topicData.cid);
|
||||
plugins.fireHook('action:topic.pin', data);
|
||||
|
||||
callback(null, {
|
||||
tid: tid,
|
||||
isPinned: pin
|
||||
});
|
||||
callback(null, data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user