mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
Post queue (#5878)
* #5876 * add user to post queue table * add time of post into queue add posting restrictions to queue * fix shouldQueueLogic for guests * add test for post-queue route
This commit is contained in:
committed by
GitHub
parent
1864a50826
commit
f161bbf956
@@ -30,6 +30,21 @@ SocketPosts.reply = function (socket, data, callback) {
|
||||
data.req = websockets.reqFromSocket(socket);
|
||||
data.timestamp = Date.now();
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
posts.shouldQueue(socket.uid, data, next);
|
||||
},
|
||||
function (shouldQueue, next) {
|
||||
if (shouldQueue) {
|
||||
posts.addToQueue(data, next);
|
||||
} else {
|
||||
postReply(socket, data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
function postReply(socket, data, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
topics.reply(data, next);
|
||||
@@ -50,7 +65,7 @@ SocketPosts.reply = function (socket, data, callback) {
|
||||
socketHelpers.notifyNew(socket.uid, 'newPost', result);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
}
|
||||
|
||||
SocketPosts.getRawPost = function (socket, pid, callback) {
|
||||
async.waterfall([
|
||||
@@ -152,3 +167,26 @@ SocketPosts.getReplies = function (socket, pid, callback) {
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
SocketPosts.accept = function (socket, data, callback) {
|
||||
acceptOrReject(posts.submitFromQueue, socket, data, callback);
|
||||
};
|
||||
|
||||
SocketPosts.reject = function (socket, data, callback) {
|
||||
acceptOrReject(posts.removeFromQueue, socket, data, callback);
|
||||
};
|
||||
|
||||
function acceptOrReject(method, socket, data, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isAdminOrGlobalMod(socket.uid, next);
|
||||
},
|
||||
function (isAdminOrGlobalMod, next) {
|
||||
if (!isAdminOrGlobalMod) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
method(data.id, next);
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user