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:
Barış Soner Uşaklı
2017-08-15 12:59:40 -04:00
committed by GitHub
parent 1864a50826
commit f161bbf956
19 changed files with 502 additions and 4 deletions

View File

@@ -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);
}