fix: #7809, dont check postDelay if submitting from queue

v1.18.x
Baris Usakli 6 years ago
parent 2abe244b6e
commit 9780f5b975

@ -45,6 +45,7 @@ exports.post = function (req, res) {
req: req,
timestamp: Date.now(),
content: body.content,
fromQueue: false,
};
req.body.noscript = 'true';

@ -127,6 +127,7 @@ module.exports = function (Posts) {
return null;
}
data.data = JSON.parse(data.data);
data.data.fromQueue = true;
return data;
}

@ -18,6 +18,13 @@ var batch = require('../batch');
var SocketHelpers = module.exports;
SocketHelpers.setDefaultPostData = function (data, socket) {
data.uid = socket.uid;
data.req = websockets.reqFromSocket(socket);
data.timestamp = Date.now();
data.fromQueue = false;
};
SocketHelpers.notifyNew = function (uid, type, result) {
async.waterfall([
function (next) {

@ -9,7 +9,6 @@ var meta = require('../meta');
var topics = require('../topics');
const categories = require('../categories');
var user = require('../user');
var websockets = require('./index');
var socketHelpers = require('./helpers');
var utils = require('../utils');
@ -29,9 +28,7 @@ SocketPosts.reply = function (socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
data.uid = socket.uid;
data.req = websockets.reqFromSocket(socket);
data.timestamp = Date.now();
socketHelpers.setDefaultPostData(data, socket);
async.waterfall([
function (next) {

@ -4,7 +4,6 @@ var async = require('async');
var topics = require('../topics');
var posts = require('../posts');
var websockets = require('./index');
var user = require('../user');
var meta = require('../meta');
var apiController = require('../controllers/api');
@ -25,9 +24,7 @@ SocketTopics.post = function (socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
data.uid = socket.uid;
data.req = websockets.reqFromSocket(socket);
data.timestamp = Date.now();
socketHelpers.setDefaultPostData(data, socket);
async.waterfall([
function (next) {

@ -88,7 +88,9 @@ module.exports = function (Topics) {
}
await guestHandleValid(data);
await user.isReadyToPost(data.uid, data.cid);
if (!data.fromQueue) {
await user.isReadyToPost(data.uid, data.cid);
}
const filteredData = await plugins.fireHook('filter:topic.post', data);
data = filteredData;
const tid = await Topics.create(data);
@ -159,7 +161,9 @@ module.exports = function (Topics) {
}
await guestHandleValid(data);
await user.isReadyToPost(uid, data.cid);
if (!data.fromQueue) {
await user.isReadyToPost(uid, data.cid);
}
await plugins.fireHook('filter:topic.reply', data);
if (data.content) {
data.content = utils.rtrim(data.content);

Loading…
Cancel
Save