Skip to content

Node.js based forum software built for the modern web

fix: don't save req into post queue

Barış Soner Uşaklı28899f7c009f
diff --git a/src/controllers/composer.js b/src/controllers/composer.js
index bc1e4283c3..9d1492932c 100644
--- a/src/controllers/composer.js
+++ b/src/controllers/composer.js
@@ -57,7 +57,6 @@ exports.post = async function (req, res) {
async function queueOrPost(postFn, data) {
const shouldQueue = await posts.shouldQueue(req.uid, data);
if (shouldQueue) {
- delete data.req;
return await posts.addToQueue(data);
}
return await postFn(data);
diff --git a/src/posts/queue.js b/src/posts/queue.js
index d8a2de903e..eadec34518 100644
--- a/src/posts/queue.js
+++ b/src/posts/queue.js
@@ -31,6 +31,9 @@ module.exports = function (Posts) {
postData.forEach((data) => {
if (data) {
data.data = JSON.parse(data.data);
+ if (data?.data?.req) {
+ delete data.data.req;
+ }
data.data.timestampISO = utils.toISOString(data.data.timestamp);
}
});
@@ -237,6 +240,9 @@ module.exports = function (Posts) {
};
payload = await plugins.hooks.fire('filter:post-queue.save', payload);
+ if (payload?.data?.req) {
+ delete payload.data.req; // dont save req into post queue
+ }
await db.sortedSetAdd('post:queue', now, id);
await db.setObject(`post:queue:${id}`, {
...payload,
diff --git a/test/posts.js b/test/posts.js
index dcf2430364..26bb488e1a 100644
--- a/test/posts.js
+++ b/test/posts.js
@@ -1033,6 +1033,7 @@ describe('Post\'s', () => {
assert.equal(posts[0].data.content, 'queued topic content');
assert.equal(posts[1].type, 'reply');
assert.equal(posts[1].data.content, 'this is a queued reply');
+ assert(!Object.hasOwn(posts[0].data, 'req'));
});
it('should error if data is invalid', async () => {